Closed fdorothy closed 6 years ago
What's the proper way to unit test a route that has a File parameter? For example, a route that would update a user's avatar on s3:
params do requires :avatar, type: File end post "/info/avatar" do # update user's avatar on S3... end
In order to test this manually I have done multipart requests with HTTPoison:
name = "avatar" filename = "avatar.png" path = "assets/avatar.png" body = {:multipart, [{:file, path, {["form-data"], [name: Poison.encode!(name), filename: Poison.encode!(filename)]},[]}]} HTTPoison.post!("http://localhost:8080/info/avatar", body)
Is there some easy way to do this in a Maru test?
You might have to make this into a helper method and wrap it into your test suite.
OOTH, providing that as a snippet + PR to Maru.Test could help as well!
Maru.Test
There's also this answer from StackOverflow - link
that works
What's the proper way to unit test a route that has a File parameter? For example, a route that would update a user's avatar on s3:
In order to test this manually I have done multipart requests with HTTPoison:
Is there some easy way to do this in a Maru test?