From 1bd7e93ff22578891c21b91310df1501c0409cab Mon Sep 17 00:00:00 2001 From: Guilherme Souza Date: Tue, 26 Mar 2024 16:31:32 -0300 Subject: [PATCH] Remove unused code from tests --- Tests/AuthTests/AuthClientTests.swift | 6 +--- Tests/AuthTests/Mocks/Mocks.swift | 40 +-------------------------- 2 files changed, 2 insertions(+), 44 deletions(-) diff --git a/Tests/AuthTests/AuthClientTests.swift b/Tests/AuthTests/AuthClientTests.swift index c5ebead4..5c447261 100644 --- a/Tests/AuthTests/AuthClientTests.swift +++ b/Tests/AuthTests/AuthClientTests.swift @@ -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 ) diff --git a/Tests/AuthTests/Mocks/Mocks.swift b/Tests/AuthTests/Mocks/Mocks.swift index da50fce2..9bc7da38 100644 --- a/Tests/AuthTests/Mocks/Mocks.swift +++ b/Tests/AuthTests/Mocks/Mocks.swift @@ -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,