File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -118,4 +118,46 @@ final class SessionManagerTests: XCTestCase {
118118 ( 0 ..< 10 ) . map { _ in validSession. accessToken }
119119 )
120120 }
121+
122+ func testRefreshSession_shouldNotRemoveSession_whenErrorIsURLErrorCancelled( ) async throws {
123+ let currentSession = Session . validSession
124+ Dependencies [ clientID] . sessionStorage. store ( currentSession)
125+
126+ await http. when (
127+ { $0. url. path. contains ( " /token " ) } ,
128+ return: { _ in
129+ throw URLError ( . cancelled)
130+ }
131+ )
132+
133+ do {
134+ _ = try await sut. refreshSession ( currentSession. refreshToken)
135+ XCTFail ( " Expected a \( URLError . cancelled) failure " )
136+ } catch let error as URLError {
137+ XCTAssertEqual ( error. code, . cancelled)
138+ }
139+
140+ XCTAssertNotNil ( Dependencies [ clientID] . sessionStorage. get ( ) )
141+ }
142+
143+ func testRefreshSession_shouldNotRemoveSession_whenErrorIsCancellationError( ) async throws {
144+ let currentSession = Session . validSession
145+ Dependencies [ clientID] . sessionStorage. store ( currentSession)
146+
147+ await http. when (
148+ { $0. url. path. contains ( " /token " ) } ,
149+ return: { _ in
150+ throw CancellationError ( )
151+ }
152+ )
153+
154+ do {
155+ _ = try await sut. refreshSession ( currentSession. refreshToken)
156+ XCTFail ( " Expected a \( CancellationError . self) failure " )
157+ } catch is CancellationError {
158+ // no-op
159+ }
160+
161+ XCTAssertNotNil ( Dependencies [ clientID] . sessionStorage. get ( ) )
162+ }
121163}
You can’t perform that action at this time.
0 commit comments