Format code with SwiftFormat automatically in every build

This commit is contained in:
Danny Moesch 2020-06-28 21:25:40 +02:00 committed by Mingshen Sun
parent f167ab7549
commit 7f9f0e43b2
100 changed files with 1124 additions and 1063 deletions

View file

@ -6,20 +6,20 @@
//
import Foundation
import XCTest
import ObjectiveGit
import XCTest
@testable import passKit
class PasswordStoreTest: XCTestCase {
let cloneOptions: [String : GTCredentialProvider] = {
let credentialProvider = GTCredentialProvider { (_, _, _) -> (GTCredential?) in
try? GTCredential(userName: "", password: "")
}
return [GTRepositoryCloneOptionsCredentialProvider: credentialProvider]
}()
let remoteRepoURL = URL(string: "https://github.com/mssun/passforios-password-store.git")!
let cloneOptions: [String: GTCredentialProvider] = {
let credentialProvider = GTCredentialProvider { (_, _, _) -> (GTCredential?) in
try? GTCredential(userName: "", password: "")
}
return [GTRepositoryCloneOptionsCredentialProvider: credentialProvider]
}()
let remoteRepoURL = URL(string: "https://github.com/mssun/passforios-password-store.git")!
func testCloneAndDecryptMultiKeys() throws {
let url = URL(fileURLWithPath: "\(Globals.repositoryPath)-test")
@ -38,8 +38,8 @@ class PasswordStoreTest: XCTestCase {
[
("work/github.com", "4712286271220DB299883EA7062E678DA1024DAE"),
("personal/github.com", "787EAE1A5FA3E749AA34CC6AA0645EBED862027E")
].forEach {(path, id) in
("personal/github.com", "787EAE1A5FA3E749AA34CC6AA0645EBED862027E"),
].forEach { path, id in
let keyID = findGPGID(from: url.appendingPathComponent(path))
XCTAssertEqual(keyID, id)
}
@ -57,17 +57,14 @@ class PasswordStoreTest: XCTestCase {
let testPassword = Password(name: "test", url: URL(string: "test.gpg")!, plainText: "testpassword")
let testPasswordEntity = try passwordStore.add(password: testPassword)!
let testPasswordPlain = try passwordStore.decrypt(passwordEntity: testPasswordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase )
let testPasswordPlain = try passwordStore.decrypt(passwordEntity: testPasswordEntity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
XCTAssertEqual(testPasswordPlain.plainText, "testpassword")
passwordStore.erase()
}
private func decrypt(passwordStore: PasswordStore, path: String, passphrase: String) throws -> Password {
private func decrypt(passwordStore: PasswordStore, path: String, passphrase _: String) throws -> Password {
let entity = passwordStore.getPasswordEntity(by: path, isDir: false)!
return try passwordStore.decrypt(passwordEntity: entity, requestPGPKeyPassphrase: requestPGPKeyPassphrase )
return try passwordStore.decrypt(passwordEntity: entity, requestPGPKeyPassphrase: requestPGPKeyPassphrase)
}
}

View file

@ -11,7 +11,6 @@ import XCTest
@testable import passKit
class PasswordTableEntryTest: XCTestCase {
func testExample() {
let nameWithCategoryList = [
"github",
@ -27,13 +26,13 @@ class PasswordTableEntryTest: XCTestCase {
]
let searchTextList1 = [
"github.com",
"www.github.com"
"www.github.com",
]
let searchTextList2 = [
"xx.com",
"www.xx.com"
"www.xx.com",
]
for nameWithCategory in nameWithCategoryList {
for searchText in searchTextList1 {
XCTAssertTrue(PasswordTableEntry.match(nameWithCategory: nameWithCategory, searchText: searchText))
@ -43,5 +42,4 @@ class PasswordTableEntryTest: XCTestCase {
}
}
}
}

View file

@ -11,7 +11,6 @@ import XCTest
@testable import passKit
class PasswordTest: XCTestCase {
func testUrl() {
let password = getPasswordObjectWith(content: "")
@ -245,7 +244,6 @@ class PasswordTest: XCTestCase {
XCTAssertEqual(password.nameFromPath, "exampleusername")
}
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!"