I have the following swift enum for returning an async API-Response:
enum Result<U: Equatable> {
case success(output: U)
case failure(error: Error)
}
For simplifying my Unit test implementation i would like to check if the returned result-enum of one of my methods equals success
I know that i can unwrap the result-enum by using the following statement
if case Result.success(let configuration) = result {
// use unwrapped configuration object
}
What i would like to archive is using a single line statement to check if the result is success when checking with expect
expect(case Result.success(let configuration) = result).to(beTrue()) <-- not compiling