@@ -605,12 +605,15 @@ class SubscriptionTests : XCTestCase {
605605
606606 var results = [ GraphQLResult] ( )
607607 var expectation = XCTestExpectation ( )
608- _ = stream. map { event in
608+
609+ // So that the Task won't immediately be cancelled since the ConcurrentEventStream is discarded
610+ let keepForNow = stream. map { event in
609611 event. map { result in
610612 results. append ( result)
611613 expectation. fulfill ( )
612614 }
613615 }
616+
614617 var expected = [ GraphQLResult] ( )
615618
616619 db. trigger ( email: Email (
@@ -675,6 +678,9 @@ class SubscriptionTests : XCTestCase {
675678 )
676679 wait ( for: [ expectation] , timeout: timeoutDuration)
677680 XCTAssertEqual ( results, expected)
681+
682+ // So that the Task won't immediately be cancelled since the ConcurrentEventStream is discarded
683+ _ = keepForNow
678684 }
679685
680686 /// 'should not trigger when subscription is already done'
@@ -701,7 +707,8 @@ class SubscriptionTests : XCTestCase {
701707
702708 var results = [ GraphQLResult] ( )
703709 var expectation = XCTestExpectation ( )
704- _ = stream. map { event in
710+ // So that the Task won't immediately be cancelled since the ConcurrentEventStream is discarded
711+ let keepForNow = stream. map { event in
705712 event. map { result in
706713 results. append ( result)
707714 expectation. fulfill ( )
@@ -747,6 +754,9 @@ class SubscriptionTests : XCTestCase {
747754 // Ensure that the current result was the one before the db was stopped
748755 wait ( for: [ expectation] , timeout: timeoutDuration)
749756 XCTAssertEqual ( results, expected)
757+
758+ // So that the Task won't immediately be cancelled since the ConcurrentEventStream is discarded
759+ _ = keepForNow
750760 }
751761
752762 /// 'should not trigger when subscription is thrown'
@@ -861,7 +871,8 @@ class SubscriptionTests : XCTestCase {
861871
862872 var results = [ GraphQLResult] ( )
863873 var expectation = XCTestExpectation ( )
864- _ = stream. map { event in
874+ // So that the Task won't immediately be cancelled since the ConcurrentEventStream is discarded
875+ let keepForNow = stream. map { event in
865876 event. map { result in
866877 results. append ( result)
867878 expectation. fulfill ( )
@@ -925,6 +936,9 @@ class SubscriptionTests : XCTestCase {
925936 )
926937 wait ( for: [ expectation] , timeout: timeoutDuration)
927938 XCTAssertEqual ( results, expected)
939+
940+ // So that the Task won't immediately be cancelled since the ConcurrentEventStream is discarded
941+ _ = keepForNow
928942 }
929943
930944 /// 'should pass through error thrown in source event stream'
0 commit comments