Description
Describe the bug
I'm using this library as part of a feature that uses TCA, and I believe that it's the CasePaths library specifically that's causing my test suite to fail to build. The app itself builds and runs as expected.
To Reproduce
I have two tests that cover both the success and failure cases of an Action
that has an associated value of Result<Void, Error>
type, used within a feature annotated with the @Reducer
macro:
@Reducer
struct MyFeature {
enum Action: Sendable {
case didFinishLoading(Result<Void, Error>)
...
}
...
}
My test cases look like this:
final class MyFeatureTests: XCTestCase {
@MainActor
func test_fetch_success() async {
let store = TestStore(initialState: MyFeature.State()) {
MyFeature()
}
await store.send(.fetch) {
$0.isFetching = true
}
await store.receive(\.setFetchingFinished.success) {
$0.isFetching = false
}
}
@MainActor
func test_fetch_failure() async {
let store = TestStore(initialState: MyFeature.State()) {
MyFeature()
} withDependencies: {
$0.fetchAction = {
throw TestError.expected
}
}
await store.send(.fetch) {
$0.isFetching = true
}
await store.receive(\.setFetchingFinished.failure) {
$0.isFetching = false
$0.navigationDestination = .alert(AlertState { TextState("Expected error.") })
}
}
}
private enum TestError: LocalizedError {
case expected
var errorDescription: String? {
switch self {
case .expected:
"Expected error."
}
}
}
Expected behavior
The test suite should build without error.
Environment
- swift-case-paths 1.4.2
- Xcode 16.0 beta 1
- Swift 6.0
- OS: macOS Sonoma 14.5
Additional context
Changing the Void
success type to some other concrete type such as Bool results in the tests building successfully. Also removing the .success
and .failure
from the case path in the .receive()
calls results in the tests building successfully.
I use the Void
type in this instance because I have an external (non-TCA) object that handles the loading and data management that the .fetch
action triggers.