summaryrefslogtreecommitdiff
path: root/TonboTests
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-02-13 02:44:02 -0800
committerFuwn <[email protected]>2025-02-13 02:44:02 -0800
commit2e22626a5b994182a5c4990d042de1c3f73e47b3 (patch)
treec7bc556b04d9092197ff366c3d1b9624dbccf62f /TonboTests
downloadtonbo-2e22626a5b994182a5c4990d042de1c3f73e47b3.tar.xz
tonbo-2e22626a5b994182a5c4990d042de1c3f73e47b3.zip
feat: Initial commitHEADmain
Diffstat (limited to 'TonboTests')
-rw-r--r--TonboTests/TonboTests.swift31
1 files changed, 31 insertions, 0 deletions
diff --git a/TonboTests/TonboTests.swift b/TonboTests/TonboTests.swift
new file mode 100644
index 0000000..a107f90
--- /dev/null
+++ b/TonboTests/TonboTests.swift
@@ -0,0 +1,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)
+ }
+ }
+}