Skip to content

Commit 2c35659

Browse files
committed
Make TaskError equatable
1 parent 5fbadcd commit 2c35659

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ReactiveTask/Errors.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,16 @@ extension TaskError: CustomStringConvertible {
3434
}
3535
}
3636
}
37+
38+
extension TaskError: Equatable {}
39+
40+
public func ==(lhs: TaskError, rhs: TaskError) -> Bool {
41+
switch (lhs, rhs) {
42+
case (.ShellTaskFailed(let lhsTask, let lhsCode, let lhsErr), .ShellTaskFailed(let rhsTask, let rhsCode, let rhsErr)):
43+
return lhsTask == rhsTask && lhsCode == rhsCode && lhsErr == rhsErr
44+
case (.POSIXError(let lhsCode), .POSIXError(let rhsCode)):
45+
return lhsCode == rhsCode
46+
default:
47+
return false
48+
}
49+
}

ReactiveTaskTests/TaskSpec.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class TaskSpec: QuickSpec {
8888

8989
expect(result).notTo(beNil())
9090
expect(result.error).toNot(beNil())
91+
expect(result.error) == TaskError.ShellTaskFailed(task, exitCode: 1, standardError: "stat: not-a-real-file: stat: No such file or directory\n")
9192
if let error = result.error {
9293
expect(error.description) == "A shell task (/usr/bin/stat not-a-real-file) failed with exit code 1:\nstat: not-a-real-file: stat: No such file or directory\n"
9394
}

0 commit comments

Comments
 (0)