Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sleipnir committed Jun 3, 2022
1 parent 487010d commit f6cbd17
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
mix deps.clean --all
mix deps.get
- name: Run tests
run: cd apps/spawn && elixir --name [email protected] -S mix test
run: cd apps/spawn && MIX_ENV=test SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= elixir --name [email protected] -S mix test
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Run tests
with:
path: apps/spawn
run: cd apps/spawn && elixir --name [email protected] -S mix test
run: cd apps/spawn && MIX_ENV=test SPAWN_STATESTORE_KEY=3Jnb0hZiHIzHTOih7t2cTEPEpY98Tu1wvQkPfq/XwqE= elixir --name [email protected] -S mix test

build-and-push-image:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions apps/statestores/lib/statestores/adapters/my_sql.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ defmodule Statestores.Adapters.MySQL do
alias Statestores.Schemas.{Event, ValueObjectSchema}

def init(_type, config) do
config =
case System.get_env("MIX_ENV") do
"test" -> Keyword.put(config, :pool, Ecto.Adapters.SQL.Sandbox)
_ -> config
end

config =
Keyword.put(config, :database, System.get_env("PROXY_DATABASE_NAME", "eigr-functions-db"))

Expand Down
6 changes: 6 additions & 0 deletions apps/statestores/lib/statestores/adapters/postgres.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ defmodule Statestores.Adapters.Postgres do
alias Statestores.Schemas.Event

def init(_type, config) do
config =
case System.get_env("MIX_ENV") do
"test" -> Keyword.put(config, :pool, Ecto.Adapters.SQL.Sandbox)
_ -> config
end

config =
Keyword.put(config, :database, System.get_env("PROXY_DATABASE_NAME", "eigr-functions-db"))

Expand Down
2 changes: 1 addition & 1 deletion apps/statestores/lib/statestores/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Statestores.Application do

@impl true
def start(_type, _args) do
type = String.to_existing_atom(System.get_env("PROXY_DATABASE_TYPE"))
type = String.to_existing_atom(System.get_env("PROXY_DATABASE_TYPE", "mysql"))
Statestores.Migrator.migrate()

children = get_supervisor_tree(type)
Expand Down
2 changes: 1 addition & 1 deletion apps/statestores/lib/statestores/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Statestores.Util do
end

def load_repo() do
type = String.to_existing_atom(System.get_env("PROXY_DATABASE_TYPE"))
type = String.to_existing_atom(System.get_env("PROXY_DATABASE_TYPE", "mysql"))
load_repo(type)
end

Expand Down
2 changes: 2 additions & 0 deletions apps/statestores/test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ExUnit.start()

Ecto.Adapters.SQL.Sandbox.mode(Statestores.Adapters.MySQL, :manual)

0 comments on commit f6cbd17

Please sign in to comment.