vapor/vapor

Make `XCTHTTPRequest` initializer public

hsharghi opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
As sending request via app.test() in tests, will not return and the response should be accessed in closures, sending multiple requests will result in a nested closures and messy code.
Using app.performTest() seemed the solution but as XCTHTTPRequest initializer is private, performTest() can not be used.

Describe the solution you'd like
Make XCTHTTPRequest initializer public so performTest() method can be used in tests cases.

Describe alternatives you've considered
As an alternative there can be new async method to send request and get the response.

@hsharghi You could use @testable import XCTVapor to access the initializer as a workaround for now.
Though this doesn't mean your issue isn't valid. It's probably better to make it public so it's guaranteed that its API won't change by Vapor.

While the compiler will allow it, and it will often seem to work, it's not actually valid - or safe - to @testable import a module from a different package, which is why XCTVapor's API is largely public rather than internal.