Skip to content

Commit

Permalink
Adopt real fulfillment API
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Jul 3, 2024
1 parent 7c0532b commit 07b4e1e
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions Tests/OAuthenticatorTests/AuthenticatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ final class AuthenticatorTests: XCTestCase {
throw AuthenticatorTestsError.disabled
}

private func compatFulfillment(of expectations: [XCTestExpectation], timeout: TimeInterval, enforceOrder: Bool) async {
#if compiler(>=5.8)
await fulfillment(of: expectations, timeout: timeout, enforceOrder: enforceOrder)
#else
await Task {
wait(for: expectations, timeout: timeout, enforceOrder: enforceOrder)
}.value
#endif
}

@MainActor
func testInitialLogin() async throws {
let authedLoadExp = expectation(description: "load url")
Expand Down Expand Up @@ -115,7 +105,7 @@ final class AuthenticatorTests: XCTestCase {

let (_, _) = try await auth.response(for: URLRequest(url: URL(string: "https://example.com")!))

Check warning on line 106 in Tests/OAuthenticatorTests/AuthenticatorTests.swift

View workflow job for this annotation

GitHub Actions / Test (platform=tvOS Simulator,name=Apple TV)

passing argument of non-sendable type 'Authenticator' outside of main actor-isolated context may introduce data races

await compatFulfillment(of: [retrieveTokenExp, userAuthExp, storeTokenExp, authedLoadExp], timeout: 1.0, enforceOrder: true)
await fulfillment(of: [retrieveTokenExp, userAuthExp, storeTokenExp, authedLoadExp], timeout: 1.0, enforceOrder: true)
}

@MainActor
Expand Down Expand Up @@ -151,7 +141,7 @@ final class AuthenticatorTests: XCTestCase {

let (_, _) = try await auth.response(for: URLRequest(url: URL(string: "https://example.com")!))

await compatFulfillment(of: [retrieveTokenExp, authedLoadExp], timeout: 1.0, enforceOrder: true)
await fulfillment(of: [retrieveTokenExp, authedLoadExp], timeout: 1.0, enforceOrder: true)
}

@MainActor
Expand Down Expand Up @@ -203,7 +193,7 @@ final class AuthenticatorTests: XCTestCase {

let (_, _) = try await auth.response(for: URLRequest(url: URL(string: "https://example.com")!))

await compatFulfillment(of: [retrieveTokenExp, refreshExp, storeTokenExp, authedLoadExp], timeout: 1.0, enforceOrder: true)
await fulfillment(of: [retrieveTokenExp, refreshExp, storeTokenExp, authedLoadExp], timeout: 1.0, enforceOrder: true)
}

@MainActor
Expand Down Expand Up @@ -258,7 +248,7 @@ final class AuthenticatorTests: XCTestCase {

let (_, _) = try await auth.response(for: URLRequest(url: URL(string: "https://example.com")!))

await compatFulfillment(of: [userAuthExp, loadExp], timeout: 1.0, enforceOrder: true)
await fulfillment(of: [userAuthExp, loadExp], timeout: 1.0, enforceOrder: true)
}

@MainActor
Expand Down Expand Up @@ -319,7 +309,7 @@ final class AuthenticatorTests: XCTestCase {

let (_, _) = try await auth.response(for: URLRequest(url: URL(string: "https://example.com")!))

await compatFulfillment(of: [userAuthExp, loadExp], timeout: 1.0, enforceOrder: true)
await fulfillment(of: [userAuthExp, loadExp], timeout: 1.0, enforceOrder: true)
}

// Test AuthenticationResultHandler with a failed UserAuthenticator
Expand Down Expand Up @@ -374,7 +364,7 @@ final class AuthenticatorTests: XCTestCase {
throw error
}

await compatFulfillment(of: [failureAuth], timeout: 1.0, enforceOrder: true)
await fulfillment(of: [failureAuth], timeout: 1.0, enforceOrder: true)
}

@MainActor
Expand Down

0 comments on commit 07b4e1e

Please sign in to comment.