mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
Fix up Tests - modify validateSession to use our network wrapper.
This commit is contained in:
parent
1496f32e28
commit
e11cdd1198
4 changed files with 16 additions and 3 deletions
|
|
@ -112,7 +112,7 @@ class AppState: ObservableObject {
|
|||
// MARK: - Authentication
|
||||
|
||||
func validateSession() -> AnyPublisher<Void, Error> {
|
||||
return client.validateSession()
|
||||
return Current.network.validateSession()
|
||||
.receive(on: DispatchQueue.main)
|
||||
.handleEvents(receiveCompletion: { completion in
|
||||
if case .failure = completion {
|
||||
|
|
|
|||
|
|
@ -183,6 +183,10 @@ public struct Network {
|
|||
public func downloadTask(with url: URL, to saveLocation: URL, resumingWith resumeData: Data?) -> (progress: Progress, publisher: AnyPublisher<(saveLocation: URL, response: URLResponse), Error>) {
|
||||
return downloadTask(url, saveLocation, resumeData)
|
||||
}
|
||||
|
||||
public var validateSession: () -> AnyPublisher<Void, Error> = {
|
||||
return client.validateSession()
|
||||
}
|
||||
}
|
||||
|
||||
public struct Keychain {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,10 @@ class AppStateTests: XCTestCase {
|
|||
return true
|
||||
}
|
||||
}
|
||||
Xcodes.Current.network.validateSession = {
|
||||
return Just(())
|
||||
.setFailureType(to: Error.self).eraseToAnyPublisher()
|
||||
}
|
||||
Xcodes.Current.network.dataTask = { urlRequest in
|
||||
// Don't have a valid session
|
||||
if urlRequest.url! == URLRequest.olympusSession.url! {
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ extension Network {
|
|||
.setFailureType(to: Error.self)
|
||||
.eraseToAnyPublisher()
|
||||
)
|
||||
},
|
||||
validateSession: {
|
||||
return Just(())
|
||||
.setFailureType(to: Error.self)
|
||||
.eraseToAnyPublisher()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue