File tree 2 files changed +12
-2
lines changed
Sources/JSONAPISwiftGen/Swift Generators/Test Generators
Tests/JSONAPISwiftGenTests
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,11 @@ public struct APIRequestTestSwiftGen: SwiftGenerator {
241
241
242
242
private let makeTestRequestFunc = #"""
243
243
244
+ /// A session stored globally that does not cache responses on disk.
245
+ let session = URLSession(
246
+ configuration: .ephemeral
247
+ )
248
+
244
249
/// Log warning after test case logs
245
250
func XCTWarn(_ message: String, at url: URL) {
246
251
print("[\(url.absoluteString)] : warning - \(message)")
@@ -401,7 +406,7 @@ func makeTestRequest<RequestBody>(
401
406
completionExpectation.fulfill()
402
407
}
403
408
404
- let task = URLSession.shared .dataTask(with: request, completionHandler: taskCompletion)
409
+ let task = session .dataTask(with: request, completionHandler: taskCompletion)
405
410
task.resume()
406
411
407
412
XCTWaiter().wait(for: [completionExpectation], timeout: 5)
Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ final class APIRequestTestSwiftGenTests: XCTestCase {
18
18
}
19
19
20
20
// MARK: - START - Function written to generated test suites
21
+ /// A session stored globally that does not cache responses on disk.
22
+ let session = URLSession (
23
+ configuration: . ephemeral
24
+ )
25
+
21
26
/// Log warning after test case logs
22
27
func XCTWarn( _ message: String , at url: URL ) {
23
28
print ( " [ \( url. absoluteString) ] : warning - \( message) " )
@@ -178,7 +183,7 @@ func makeTestRequest<RequestBody>(
178
183
completionExpectation. fulfill ( )
179
184
}
180
185
181
- let task = URLSession . shared . dataTask ( with: request, completionHandler: taskCompletion)
186
+ let task = session . dataTask ( with: request, completionHandler: taskCompletion)
182
187
task. resume ( )
183
188
184
189
XCTWaiter ( ) . wait ( for: [ completionExpectation] , timeout: 5 )
You can’t perform that action at this time.
0 commit comments