-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: simplify auth tests mocks (#243)
- Loading branch information
Showing
9 changed files
with
251 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// MockSessionManager.swift | ||
// | ||
// | ||
// Created by Guilherme Souza on 16/02/24. | ||
// | ||
|
||
@testable import Auth | ||
import ConcurrencyExtras | ||
import Foundation | ||
|
||
final class MockSessionManager: SessionManager { | ||
private let _returnSession = LockIsolated(Result<Session, Error>?.none) | ||
var returnSession: Result<Session, Error>? { | ||
get { _returnSession.value } | ||
set { _returnSession.setValue(newValue) } | ||
} | ||
|
||
func session(shouldValidateExpiration _: Bool) async throws -> Auth.Session { | ||
try returnSession!.get() | ||
} | ||
|
||
func update(_: Auth.Session) async throws {} | ||
|
||
private let _removeCallCount = LockIsolated(0) | ||
var removeCallCount: Int { | ||
get { _removeCallCount.value } | ||
set { _removeCallCount.setValue(newValue) } | ||
} | ||
|
||
var removeCalled: Bool { removeCallCount > 0 } | ||
func remove() async { | ||
_removeCallCount.withValue { $0 += 1 } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.