CrowdHailer / raxx

Interface for HTTP webservers, frameworks and clients
https://hexdocs.pm/raxx
Apache License 2.0
402 stars 29 forks source link

Document testing approach for raxx apps #70

Closed lpil closed 6 years ago

lpil commented 6 years ago

Hey!

Could you document the recommended approach of testing raxx apps please? Are there some handy helper functions we can use? :)

Cheers, Louis

CrowdHailer commented 6 years ago

Don't need a helper function.

import Raxx

response = request(:GET, "/")
|> set_header("accept", "application/json")
|> MyApp.handle_request(config)

assert response.status == 200
assert response.body == "Hello, World!"

That's what I do in simple cases.

If I am testing streaming I normally start a server for every test and use HTTPoison (or :gen_tcp). https://github.com/CrowdHailer/Ace/blob/master/test/ace/http1/server_test.exs#L4-L15

You are right a pointer in the README would probably be benificial

lpil commented 6 years ago

Fab, I didn't spot the request function :)

CrowdHailer commented 6 years ago

@lpil Any more questions on this issue?

Did you get it working? If you want to start a Testing section PR that be great, even if it has some missing bits or questions. I should be able to contribute more next week

lpil commented 6 years ago

I'm happy, though I've not got round to doing any testing myself. May end up using Phoenix/Plug/Cowboy for the websockets pubsub.

CrowdHailer commented 6 years ago

Unfortunately if websockets are required then that is probably the right solution. I think websockets don't have a home once you are mostly running on HTTP/2 but that is not the reality at the moment.

Will close this for now

lpil commented 6 years ago

Yee, HTTP2 sounds like a good solution, we're just not quite there yet.

Thanks again :)