Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Dec 14, 2023
1 parent 80f9e3b commit 2c97100
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 18 deletions.
3 changes: 3 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ let package = Package(
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
],
exclude: [
"__Snapshots__",
],
resources: [.process("Resources")]
),
.target(
Expand Down
14 changes: 7 additions & 7 deletions Supabase.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
"name" : "FunctionsTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "GoTrueTests",
"name" : "GoTrueTests"
}
},
{
"target" : {
"containerPath" : "container:",
Expand Down Expand Up @@ -60,6 +53,13 @@
"identifier" : "SupabaseTests",
"name" : "SupabaseTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AuthTests",
"name" : "AuthTests"
}
}
],
"version" : 1
Expand Down
20 changes: 20 additions & 0 deletions Tests/AuthTests/Mocks/Mocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,23 @@ extension Session {
user: User(fromMockNamed: "user")
)
}

final class InMemoryLocalStorage: AuthLocalStorage, @unchecked Sendable {
let storage = LockIsolated([String: Data]())

func store(key: String, value: Data) throws {
storage.withValue {
$0[key] = value
}
}

func retrieve(key: String) throws -> Data? {
storage.value[key]
}

func remove(key: String) throws {
storage.withValue {
$0[key] = nil
}
}
}
5 changes: 4 additions & 1 deletion Tests/AuthTests/RequestsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,20 @@ final class RequestsTests: XCTestCase {

private func makeSUT(
record: Bool = false,
flowType: AuthFlowType = .implicit,
fetch: AuthClient.FetchHandler? = nil,
file: StaticString = #file,
testName: String = #function,
line: UInt = #line
) -> AuthClient {
let encoder = JSONEncoder.goTrue
let encoder = AuthClient.Configuration.jsonEncoder
encoder.outputFormatting = .sortedKeys

let configuration = AuthClient.Configuration(
url: clientURL,
headers: ["apikey": "dummy.api.key", "X-Client-Info": "gotrue-swift/x.y.z"],
flowType: flowType,
localStorage: InMemoryLocalStorage(),
encoder: encoder,
fetch: { request in
DispatchQueue.main.sync {
Expand Down
20 changes: 10 additions & 10 deletions supabase-swift.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"state" : {
"revision" : "5da6989aae464f324eef5c5b52bdb7974725ab81",
"version" : "1.0.0"
"revision" : "bba1111185863c9288c5f047770f421c3b7793a4",
"version" : "1.1.3"
}
},
{
Expand All @@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-custom-dump",
"state" : {
"revision" : "3efbfba0e4e56c7187cc19137ee16b7c95346b79",
"version" : "1.1.0"
"revision" : "aedcf6f4cd486ccef5b312ccac85d4b3f6e58605",
"version" : "1.1.2"
}
},
{
Expand All @@ -68,26 +68,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "bb0ea08db8e73324fe6c3727f755ca41a23ff2f4",
"version" : "1.14.2"
"revision" : "59b663f68e69f27a87b45de48cb63264b8194605",
"version" : "1.15.1"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
"identity" : "swiftui-navigation",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swiftui-navigation.git",
"state" : {
"revision" : "6eb293c49505d86e9e24232cb6af6be7fff93bd5",
"version" : "1.0.2"
"revision" : "78f9d72cf667adb47e2040aa373185c88c63f0dc",
"version" : "1.2.0"
}
},
{
Expand Down

0 comments on commit 2c97100

Please sign in to comment.