Adds prefix to xctFail on fail action.
This commit is contained in:
@@ -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):
|
||||||
XCTFail("\(error)")
|
if let prefix {
|
||||||
|
XCTFail("\(prefix): \(error)")
|
||||||
|
} else {
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user