Skip to content

Commit 92014dd

Browse files
committed
[Test] Improve testTry_success by checking retry-stop on fulfilled before reaching maxTryCount.
1 parent bb658b4 commit 92014dd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

SwiftTaskTests/SwiftTaskTests.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,14 +922,15 @@ class SwiftTaskTests: _TestCase
922922
var expect = self.expectationWithDescription(__FUNCTION__)
923923
var maxTryCount = 3
924924
var actualTryCount = 0
925+
let fulfilledTryCount = 2
925926

926927
Task<Float, String, ErrorString> { progress, fulfill, reject, configure in
927928

928929
self.perform {
929930

930931
actualTryCount++
931932

932-
if actualTryCount < maxTryCount {
933+
if actualTryCount != fulfilledTryCount {
933934
reject("ERROR \(actualTryCount)")
934935
}
935936
else {
@@ -951,6 +952,8 @@ class SwiftTaskTests: _TestCase
951952
}
952953

953954
self.wait()
955+
956+
XCTAssertEqual(actualTryCount, fulfilledTryCount, "`actualTryCount` should be stopped at `fulfilledTryCount`, not `maxTryCount`.")
954957
}
955958

956959
func testTry_failure()
@@ -962,7 +965,7 @@ class SwiftTaskTests: _TestCase
962965
var maxTryCount = 3
963966
var actualTryCount = 0
964967

965-
let t = Task<Float, String, ErrorString> { progress, fulfill, reject, configure in
968+
Task<Float, String, ErrorString> { progress, fulfill, reject, configure in
966969

967970
self.perform {
968971
actualTryCount++
@@ -981,6 +984,8 @@ class SwiftTaskTests: _TestCase
981984
}
982985

983986
self.wait()
987+
988+
XCTAssertEqual(actualTryCount, maxTryCount, "`actualTryCount` should reach `maxTryCount` because task keeps rejected and never fulfilled.")
984989
}
985990

986991
func testTry_progress()

0 commit comments

Comments
 (0)