Adds prefix to xctFail on fail action.

This commit is contained in:
2024-02-24 17:43:08 -05:00
parent 74e10b704c
commit 0a35a708f5

View File

@@ -80,23 +80,27 @@ extension Reducer {
} }
public enum OnFailAction<State> { public enum OnFailAction<State> {
case xctFail case xctFail(prefix: String? = nil)
case handle((inout State, Error) -> Void) case handle((inout State, Error) -> Void)
@usableFromInline @usableFromInline
func callAsFunction(state: inout State, error: Error) { func callAsFunction(state: inout State, error: Error) {
switch self { switch self {
case .xctFail: case let .xctFail(prefix):
if let prefix {
XCTFail("\(prefix): \(error)")
} else {
XCTFail("\(error)") XCTFail("\(error)")
}
case let .handle(handler): case let .handle(handler):
handler(&state, error) handler(&state, error)
} }
} }
} }
fileprivate extension WritableKeyPath { extension WritableKeyPath {
func callAsFunction(root: inout Root, value: Value) { public func callAsFunction(root: inout Root, value: Value) {
root[keyPath: self] = value root[keyPath: self] = value
} }