Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
get tests building
Kabir Oberaida05f4ad5f79
diff --git a/Tests/SupersignTests/Tests/SupersignDeveloperServicesTests.swift b/Tests/SupersignTests/Tests/SupersignDeveloperServicesTests.swiftindex d943eb9..a86c0e1 100644--- a/Tests/SupersignTests/Tests/SupersignDeveloperServicesTests.swift+++ b/Tests/SupersignTests/Tests/SupersignDeveloperServicesTests.swift@@ -30,9 +30,9 @@ class SupersignDeveloperServicesTests: XCTestCase {}// integration test for provisioning- func testProvisioningIntegration() throws {+ func testProvisioningIntegration() async throws {let listTeams = DeveloperServicesListTeamsRequest()- let teams = try XCTTry(client.sendTest(listTeams))+ let teams = try await client.send(listTeams)let team = teams.first { $0.status == "active" && $0.memberships.contains { $0.platform == .iOS } }!let source = try XCTUnwrap(Bundle.module.url(forResource: "test", withExtension: "app"))@@ -45,21 +45,18 @@ class SupersignDeveloperServicesTests: XCTestCase {signingInfoManager: MemoryBackedSigningInfoManager()))- let waiter = ResultWaiter<DeveloperServicesProvisioningOperation.Response>(description: "Failed to provision")- DeveloperServicesProvisioningOperation(+ let response = try await DeveloperServicesProvisioningOperation(context: context,app: source,- confirmRevocation: { $1(true) },+ confirmRevocation: { _ in true },progress: { _ in }- ).perform(completion: waiter.completion)- let response = try XCTTry(waiter.wait(timeout: 10000))-+ ).perform()print(response)}- func testListTeams() throws {+ func testListTeams() async throws {let listTeams = DeveloperServicesListTeamsRequest()- let teams = try XCTTry(client.sendTest(listTeams))+ let teams = try await client.send(listTeams)XCTAssertFalse(teams.isEmpty, "No teams found")let team = try XCTUnwrap(diff --git a/Tests/SupersignTests/Tests/SupersignGrandSlamTests.swift b/Tests/SupersignTests/Tests/SupersignGrandSlamTests.swiftindex c98054f..e47a818 100644--- a/Tests/SupersignTests/Tests/SupersignGrandSlamTests.swift+++ b/Tests/SupersignTests/Tests/SupersignGrandSlamTests.swift@@ -12,10 +12,10 @@ import XCTestimport SuperutilsTestSupport@testable import Supersign-class TwoFactorAuthenticator: TwoFactorAuthDelegate {- func fetchCode(completion: @escaping (String?) -> Void) {+final class TwoFactorAuthenticator: TwoFactorAuthDelegate {+ func fetchCode() async -> String? {print("Code: ", terminator: "")- completion(readLine() ?? "")+ return readLine() ?? ""}}@@ -39,15 +39,13 @@ class SupersignGrandSlamTests: XCTestCase {authenticator = nil}- func testAuthentication() throws {- let authWaiter = ResultWaiter<GrandSlamLoginData>(description: "Login timed out")- GrandSlamAuthenticateOperation(+ func testAuthentication() async throws {+ let loginData = try await GrandSlamAuthenticateOperation(client: client,username: Config.current.appleID.username,password: Config.current.appleID.password,twoFactorDelegate: authenticator- ).authenticate(completion: authWaiter.completion)- let loginData = try XCTTry(authWaiter.wait(timeout: 10000))+ ).authenticate()XCTAssertFalse(loginData.adsid.isEmpty)XCTAssertFalse(loginData.cookie.isEmpty)XCTAssertFalse(loginData.identityToken.isEmpty)@@ -56,15 +54,11 @@ class SupersignGrandSlamTests: XCTestCase {let now = Date() // *before* the actual request is made- let tokWaiter = ResultWaiter<[AppTokenKey: GrandSlamFetchAppTokensOperation.Token]>(- description: "Token request timed out"- )- GrandSlamFetchAppTokensOperation(+ let tokens = try await GrandSlamFetchAppTokensOperation(client: client,apps: [.xcode],loginData: loginData- ).perform(completion: tokWaiter.completion)- let tokens = try XCTTry(tokWaiter.wait(timeout: 10000))+ ).perform()let token = try XCTUnwrap(tokens[.xcode], "Xcode token absent from response")XCTAssertGreaterThanOrEqual(token.expiry, now)XCTAssertFalse(token.value.isEmpty)diff --git a/Tests/SupersignTests/Utilities/DeveloperServicesClient+Testing.swift b/Tests/SupersignTests/Utilities/DeveloperServicesClient+Testing.swiftindex d6f6039..b80e2ba 100644--- a/Tests/SupersignTests/Utilities/DeveloperServicesClient+Testing.swift+++ b/Tests/SupersignTests/Utilities/DeveloperServicesClient+Testing.swift@@ -33,7 +33,7 @@ extension NetcatAnisetteDataProvider {extension ADIDataProvider {static func test(storage: KeyValueStorage) throws -> ADIDataProvider {- try supersetteProvider(deviceInfo: Config.current.deviceInfo, storage: storage)+ try adiProvider(deviceInfo: Config.current.deviceInfo, storage: storage)}}@@ -59,12 +59,4 @@ extension DeveloperServicesClient {)}- func sendTest<T: DeveloperServicesRequest>(- _ request: T, file: StaticString = #file, line: UInt = #line- ) throws -> T.Value {- let waiter = ResultWaiter<T.Value>(description: "Could not finish request: \(request.action)")- send(request, completion: waiter.completion)- return try waiter.wait(timeout: 10, file: file, line: line)- }-}diff --git a/Tests/SupersignTests/Utilities/ResultWaiter.swift b/Tests/SupersignTests/Utilities/ResultWaiter.swiftdeleted file mode 100644index 3b78b2c..0000000--- a/Tests/SupersignTests/Utilities/ResultWaiter.swift+++ /dev/null@@ -1,36 +0,0 @@-//-// ResultWaiter.swift-// SupersignTests-//-// Created by Kabir Oberai on 30/10/19.-// Copyright © 2019 Kabir Oberai. All rights reserved.-//--import Foundation-import XCTest--class ResultWaiter<T> {-- private let waiter = XCTWaiter()- private let expectation: XCTestExpectation- private(set) var completion: ((Result<T, Error>) -> Void)- private var result: Result<T, Error>?-- init(description: String) {- let expectation = XCTestExpectation(description: description)- self.expectation = expectation- // this stub is needed to allow the initialization phase to finish,- // since we can't access self.result until that's done- self.completion = { _ in }- self.completion = { result in- self.result = result- expectation.fulfill()- }- }-- func wait(timeout: TimeInterval, file: StaticString = #file, line: UInt = #line) throws -> T {- waiter.wait(for: [expectation], timeout: timeout)- return try XCTUnwrap(result, file: file, line: line).get()- }--}