@@ -605,12 +605,15 @@ class SubscriptionTests : XCTestCase {
605
605
606
606
var results = [ GraphQLResult] ( )
607
607
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
609
611
event. map { result in
610
612
results. append ( result)
611
613
expectation. fulfill ( )
612
614
}
613
615
}
616
+
614
617
var expected = [ GraphQLResult] ( )
615
618
616
619
db. trigger ( email: Email (
@@ -675,6 +678,9 @@ class SubscriptionTests : XCTestCase {
675
678
)
676
679
wait ( for: [ expectation] , timeout: timeoutDuration)
677
680
XCTAssertEqual ( results, expected)
681
+
682
+ // So that the Task won't immediately be cancelled since the ConcurrentEventStream is discarded
683
+ _ = keepForNow
678
684
}
679
685
680
686
/// 'should not trigger when subscription is already done'
@@ -701,7 +707,8 @@ class SubscriptionTests : XCTestCase {
701
707
702
708
var results = [ GraphQLResult] ( )
703
709
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
705
712
event. map { result in
706
713
results. append ( result)
707
714
expectation. fulfill ( )
@@ -747,6 +754,9 @@ class SubscriptionTests : XCTestCase {
747
754
// Ensure that the current result was the one before the db was stopped
748
755
wait ( for: [ expectation] , timeout: timeoutDuration)
749
756
XCTAssertEqual ( results, expected)
757
+
758
+ // So that the Task won't immediately be cancelled since the ConcurrentEventStream is discarded
759
+ _ = keepForNow
750
760
}
751
761
752
762
/// 'should not trigger when subscription is thrown'
@@ -861,7 +871,8 @@ class SubscriptionTests : XCTestCase {
861
871
862
872
var results = [ GraphQLResult] ( )
863
873
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
865
876
event. map { result in
866
877
results. append ( result)
867
878
expectation. fulfill ( )
@@ -925,6 +936,9 @@ class SubscriptionTests : XCTestCase {
925
936
)
926
937
wait ( for: [ expectation] , timeout: timeoutDuration)
927
938
XCTAssertEqual ( results, expected)
939
+
940
+ // So that the Task won't immediately be cancelled since the ConcurrentEventStream is discarded
941
+ _ = keepForNow
928
942
}
929
943
930
944
/// 'should pass through error thrown in source event stream'
0 commit comments