Refactor core data classes (#671)

This commit is contained in:
Mingshen Sun 2025-01-25 15:40:12 -08:00 committed by GitHub
parent ab453580ad
commit d1de81d919
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 605 additions and 433 deletions

View file

@ -14,7 +14,7 @@ final class PasswordTest: XCTestCase {
func testURL() {
let password = getPasswordObjectWith(content: "")
XCTAssertEqual(password.url, PASSWORD_URL)
XCTAssertEqual(password.path, PASSWORD_PATH)
XCTAssertEqual(password.namePath, PASSWORD_PATH)
}
@ -242,11 +242,17 @@ final class PasswordTest: XCTestCase {
}
func testUsernameInPath() {
let password = getPasswordObjectWith(content: "", url: URL(fileURLWithPath: "exampleservice/exampleusername.pgp"))
let password = getPasswordObjectWith(content: "", path: "exampleservice/exampleusername.pgp")
XCTAssertEqual(password.nameFromPath, "exampleusername")
}
func testDotInFilename() {
let password = getPasswordObjectWith(content: "", path: "exampleservice/..pgp")
XCTAssertEqual(password.nameFromPath, ".")
}
func testMultilineValues() {
let lineBreakField = "with line breaks" => "|\n This is \n text spread over \n multiple lines! "
let noLineBreakField = "without line breaks" => " > \n This is \n text spread over\n multiple lines!"
@ -283,16 +289,16 @@ final class PasswordTest: XCTestCase {
let password = getPasswordObjectWith(content: "")
XCTAssertEqual(password.changed, 0)
password.updatePassword(name: "password", url: PASSWORD_URL, plainText: "")
password.updatePassword(name: "password", path: PASSWORD_PATH, plainText: "")
XCTAssertEqual(password.changed, 0)
password.updatePassword(name: "", url: PASSWORD_URL, plainText: "a")
password.updatePassword(name: "", path: PASSWORD_PATH, plainText: "a")
XCTAssertEqual(password.changed, 2)
password.updatePassword(name: "", url: URL(fileURLWithPath: "/some/path/"), plainText: "a")
password.updatePassword(name: "", path: "/some/path/", plainText: "a")
XCTAssertEqual(password.changed, 3)
password.updatePassword(name: "", url: PASSWORD_URL, plainText: "")
password.updatePassword(name: "", path: PASSWORD_PATH, plainText: "")
XCTAssertEqual(password.changed, 3)
}