Skip to content

Commit

Permalink
Remove unused code from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Mar 26, 2024
1 parent 32ccb5b commit 1bd7e93
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
6 changes: 1 addition & 5 deletions Tests/AuthTests/AuthClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,11 @@ final class AuthClientTests: XCTestCase {
XCTAssertEqual(removeCallCount.value, 1)
}

func testSignUpWithSessionResponse() async throws {
sut = makeSUT()
}

private func makeSUT() -> AuthClient {
let configuration = AuthClient.Configuration(
url: clientURL,
headers: ["Apikey": "dummy.api.key"],
localStorage: Dependencies.localStorage,
localStorage: InMemoryLocalStorage(),
logger: nil
)

Expand Down
40 changes: 1 addition & 39 deletions Tests/AuthTests/Mocks/Mocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,49 +44,11 @@ extension SessionRefresher {
static let mock = Self(refreshSession: unimplemented("SessionRefresher.refreshSession"))
}

struct InsecureMockLocalStorage: AuthLocalStorage {
private let defaults: UserDefaults

init(service: String, accessGroup _: String?) {
guard let defaults = UserDefaults(suiteName: service) else {
fatalError("Unable to create defautls for service: \(service)")
}

self.defaults = defaults
}

func store(key: String, value: Data) throws {
print("[WARN] YOU ARE YOU WRITING TO INSECURE LOCAL STORAGE")
defaults.set(value, forKey: key)
}

func retrieve(key: String) throws -> Data? {
print("[WARN] YOU ARE READING FROM INSECURE LOCAL STORAGE")
return defaults.data(forKey: key)
}

func remove(key: String) throws {
print("[WARN] YOU ARE REMOVING A KEY FROM INSECURE LOCAL STORAGE")
defaults.removeObject(forKey: key)
}
}

extension Dependencies {
static let localStorage: some AuthLocalStorage = {
#if !os(Linux) && !os(Windows)
KeychainLocalStorage(service: "supabase.gotrue.swift", accessGroup: nil)
#elseif os(Windows)
WinCredLocalStorage(service: "supabase.gotrue.swift")
#else
// Only use an insecure mock when needed for testing
InsecureMockLocalStorage(service: "supabase.gotrue.swift", accessGroup: nil)
#endif
}()

static let mock = Dependencies(
configuration: AuthClient.Configuration(
url: clientURL,
localStorage: Self.localStorage,
localStorage: InMemoryLocalStorage(),
logger: nil
),
sessionManager: .mock,
Expand Down

0 comments on commit 1bd7e93

Please sign in to comment.