blob: a107f9027621fc3565355a50ee1fe4896815171f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import Testing
import Foundation
import Apollo
import Tonbo
struct TonboTests {
private let apolloClient = ApolloClient(url: URL(string: "https://graphql.anilist.co")!)
private func fetchUserID(completion: @escaping (Int) -> Void) {
apolloClient.fetch(query: UserIDQuery()) { result in
switch result {
case .success(let graphQLResult):
if let userID = graphQLResult.data?.user?.id {
completion(userID)
} else if let errors = graphQLResult.errors {
print(errors)
completion(-1)
}
case .failure(let error):
print(error)
completion(-2)
}
}
}
@Test private func userIDQuery() async throws {
fetchUserID { userID in
#expect(userID == 5678223)
}
}
}
|