Browse Source

Fix test for macOS

onevcat 5 years ago
parent
commit
c8975af59e
1 changed files with 4 additions and 2 deletions
  1. 4 2
      Tests/KingfisherTests/RetryStrategyTests.swift

+ 4 - 2
Tests/KingfisherTests/RetryStrategyTests.swift

@@ -146,11 +146,13 @@ class RetryStrategyTests: XCTestCase {
         var blockCalled: [Bool] = []
         var blockCalled: [Bool] = []
         let source = Source.network(URL(string: "url")!)
         let source = Source.network(URL(string: "url")!)
         let retry = DelayRetryStrategy(maxRetryCount: 3, retryInterval: .seconds(0))
         let retry = DelayRetryStrategy(maxRetryCount: 3, retryInterval: .seconds(0))
+
+        let task = URLSession.shared.dataTask(with: URL(string: "url")!)
+
         let context1 = RetryContext(
         let context1 = RetryContext(
             source: source,
             source: source,
-            error: .requestError(reason: .taskCancelled(task: .init(task: .init()), token: .init()))
+            error: .requestError(reason: .taskCancelled(task: .init(task: task), token: .init()))
         )
         )
-
         retry.retry(context: context1) { decision in
         retry.retry(context: context1) { decision in
             guard case RetryDecision.stop = decision else {
             guard case RetryDecision.stop = decision else {
                 XCTFail("The decision should be `stop` if user cancelled the task.")
                 XCTFail("The decision should be `stop` if user cancelled the task.")