I'm testing an S3 connection with fakeS3 and it works perfectly. The only downside is I have to run the fake S3 server every time before I run my tests or the S3 test will break obviously.
I want to figure out a way to run this command before my test run:
fakes3 -r ~/.s3bucket -p 4567
This will in theory start the Sinatra server so that the S3 test will pass but I don't need to start a separate server each time.
I've tried this and it didn't work for good reason:
MIX.exs
test: ["ecto.create --quiet", "ecto.migrate", "fakes3 -r ~/.s3bucket -p 4567", "test"]
That doesn't work because it's not a mix task.
I'm also probably thinking of this the wrong way. How can I have the command run before my tests and is this the right way to think about this problem?
Just use
ExUnit.Callbacks.setup_all/1
:The above is to be put into the case you use to test S3.
BTW, this could be done with
mix
as well. It hasrun
task that accepts either the script to run or an expression to eval as an argument: