Skip to content

Commit fa2f26b

Browse files
committed
add docker-compose to manage test db
1 parent 4019b0a commit fa2f26b

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,13 @@ Catelog.roots() |> Repo.all
252252
## Contributing
253253
First, set appropriate settings for test database.
254254
```shell
255-
export POSTGRES_USER=test_username POSTGRES_PASSWORD=test_password MIX_ENV=test
255+
export POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres MIX_ENV=test
256+
257+
docker-compose up
258+
259+
mix do ecto.create, ecto.migrate
256260
```
261+
257262
run test.
258263
```elixir
259264
mix test

config/test.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ config :hierarch, ecto_repos: [Dummy.Repo]
55

66
config :hierarch, Dummy.Repo,
77
adapter: Ecto.Adapters.Postgres,
8-
username: System.get_env("POSTGRES_USER") || "postgres",
9-
password: System.get_env("POSTGRES_PASSWORD") || "posgtres",
8+
username: System.get_env("POSTGRES_USER", "postgres"),
9+
password: System.get_env("POSTGRES_PASSWORD", "postgres"),
1010
database: "hierarch_test",
1111
hostname: "localhost",
1212
pool: Ecto.Adapters.SQL.Sandbox,

docker-compose.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
image: postgres:9.5-alpine
6+
environment:
7+
POSTGRES_USER: postgres
8+
POSTGRES_PASSWORD: postgres
9+
POSTGRES_DB: hierarch_test
10+
ports:
11+
- 5432:5432

0 commit comments

Comments
 (0)