Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCTExecute returning values and throwing errors #157

Merged
merged 2 commits into from
Jan 17, 2023
Merged

Conversation

adam-fowler
Copy link
Member

This is a breaking change:
HBApplication.XCTExecute will now return the value the supplied closure returns. This simplifies testing code where you need a value from one response to use in the next.

var optionalHeader: String?
app.XCTExecute(uri: "/", method: .GET) { response in
    optionalHeader = response.header["my-header"].first
}
let header = try XCTUnwrap(optionalHeader)

now becomes

let header = try app.XCTExecute(uri: "/", method: .GET) { response in
    return response.header["my-header"].first
}

which is much cleaner.

To get this to work though requires XCTExecute to throw errors

@adam-fowler adam-fowler merged commit 30e92b0 into main Jan 17, 2023
@adam-fowler adam-fowler deleted the feature/xct-try branch January 17, 2023 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant