I have a habit of keeping a docker-compose.yml
in the repo
to avoid having to install and configure postgres from scratch.
If you do not/cannot use docker, skip the first step, then just install and configure
postgres normally.
- Start Postgres:
docker-compose up -d
- Install dependencies with:
mix deps.get
- Create and migrate the database with:
mix ecto.create && mix ecto.migrate
(bonus: use an alias frommix.exs
) - Start Phoenix endpoint with
mix phoenix.server
Now the endpoint (server) will be listening for requests at localhost:4000
.
Elixir comes with ExUnit
and phoenix provides some test helpers. Similar to rspec, the tests
folder normally
mimics the directory structure of your app and contains files of the same name with _test.exs
appended to the end: file_name_test.exs
.
Note: .exs
vs. .ex
(left is usually for scripting)
I have added some things to make testing a little cooler:
- Bureaucrat (for autogenerating api-docs from tests)
- ExMachina (easily create test data, kinda like factory girl)
- Faker (generate fake data, pairs nice with exmachne)
- credo (linting/code analysis, look at
.credo.exs
) - mix_test.watch (watchs files while testing, configured to run credo as well)
- try this out with:
mix test.watch
(tests run and then credo runs, every file save)
- try this out with:
To much to explain in a little readme to I took some screenshots of the observer app that ships with erlang. This app looks much pretty on OSX but I was running linux at the time of the screenshot so the interface is only ok.
This is the application tree:
These are some load charts:
This is just some system info: