Skip to content

Commit a393f06

Browse files
committed
Fix tests
1 parent 683797e commit a393f06

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Sources/ComposableArchitecture/TestStore.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ extension TestStore {
18951895
)
18961896

18971897
for effect in self.reducer.inFlightEffects {
1898-
_ = Effect<Never, Never>.cancel(id: effect.id).producer.startWithValues { _ in }
1898+
_ = Effect<Never, Never>.cancel(id: effect.id).producer.startWithCompleted {}
18991899
}
19001900
self.reducer.inFlightEffects = []
19011901
}
@@ -2215,7 +2215,8 @@ private func _XCTExpectFailure(
22152215
strict: Bool = true,
22162216
failingBlock: () -> Void
22172217
) {
2218-
#if DEBUG
2218+
// Obj-C runtime functions not supported on Linux, e.g. `NSSelectorFromString`
2219+
#if DEBUG && !os(Linux)
22192220
guard
22202221
let XCTExpectedFailureOptions = NSClassFromString("XCTExpectedFailureOptions")
22212222
as Any as? NSObjectProtocol,

Tests/ComposableArchitectureTests/TestStoreNonExhaustiveTests.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
#if DEBUG
1+
2+
// `@MainActor` introduces issues gathering tests on Linux
3+
#if DEBUG && !os(Linux)
24
import ComposableArchitecture
5+
import ReactiveSwift
36
import XCTest
47

58
@MainActor
@@ -493,7 +496,7 @@
493496
}
494497

495498
func testPartialExhaustivityPrefix() async {
496-
let testScheduler = DispatchQueue.test
499+
let testScheduler = TestScheduler()
497500
enum Action {
498501
case buttonTapped
499502
case response(Int)
@@ -668,14 +671,14 @@
668671
// This example comes from Krzysztof Zabłocki's blog post:
669672
// https://www.merowing.info/exhaustive-testing-in-tca/
670673
func testKrzysztofExample3() {
671-
let mainQueue = DispatchQueue.test
674+
let mainQueue = TestScheduler()
672675

673676
let store = TestStore(
674677
initialState: KrzysztofExample.State(),
675678
reducer: KrzysztofExample()
676679
)
677680
store.exhaustivity = .off
678-
store.dependencies.mainQueue = mainQueue.eraseToAnyScheduler()
681+
store.dependencies.mainQueue = mainQueue
679682

680683
store.send(.advanceAgeAndMoodAfterDelay)
681684
mainQueue.advance(by: 1)
@@ -770,8 +773,7 @@
770773
.init(value: .changeAge(state.age + 1)),
771774
.init(value: .changeMood(state.mood + 1))
772775
)
773-
.delay(for: 1, scheduler: self.mainQueue)
774-
.eraseToEffect()
776+
.deferred(for: 1, scheduler: self.mainQueue)
775777

776778
case let .changeAge(age):
777779
state.age = age

0 commit comments

Comments
 (0)