Skip to content

Commit 0d1d3b6

Browse files
Mark Pospeselmpospese
authored andcommitted
[Issue-9] Reset engine flag when done
1 parent 46d5f1d commit 0d1d3b6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Tests/YNetworkTests/NetworkManager/NetworkManagerDownloadTests.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ final class NetworkManagerDownloadTests: XCTestCase {
130130

131131
let engine = try XCTUnwrap(sut.configuration?.networkEngine as? URLProtocolStubNetworkEngine)
132132
engine.autoResumesBackgroundTasks = false
133+
defer {
134+
engine.autoResumesBackgroundTasks = true
135+
}
133136

134137
URLProtocolStub.appendStub(withData: makeData(), statusCode: 200, type: .download)
135138

@@ -139,7 +142,7 @@ final class NetworkManagerDownloadTests: XCTestCase {
139142
task.cancel() // this will make it fail
140143
task.resume() // resume it
141144

142-
wait(for: [expectation], timeout: 1.0)
145+
wait(for: [expectation], timeout: timeout)
143146

144147
XCTAssertNotNil(sut.receivedError)
145148
}

Tests/YNetworkTests/NetworkManager/NetworkManagerUploadTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ final class NetworkManagerUploadTests: XCTestCase {
6666

6767
let engine = try XCTUnwrap(sut.configuration?.networkEngine as? URLProtocolStubNetworkEngine)
6868
engine.autoResumesBackgroundTasks = false
69+
defer {
70+
engine.autoResumesBackgroundTasks = true
71+
}
6972

7073
URLProtocolStub.appendStub(withData: data, statusCode: 200, type: .upload)
7174

0 commit comments

Comments
 (0)