You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
960 B

defmodule Mix.Tasks.Test.Integration do
use Mix.Task
@shortdoc "Runs integration tests with REQUIRE_DB=true (requires PostgreSQL)"
@moduledoc """
Creates the test database if needed, runs migrations, then runs tests tagged `:integration`.
Spawns a subprocess with `REQUIRE_DB=true` so the application starts `GcIndexRelay.Repo`
under `MIX_ENV=test`. Extra args are forwarded to `mix test` (e.g. `--failed`, `--trace` for line-by-line output).
"""
@impl Mix.Task
def run(args) do
Mix.Task.run("loadconfig")
argv =
[
"REQUIRE_DB=true",
"MIX_ENV=test",
"mix",
"do",
"ecto.create",
"--quiet",
"+",
"ecto.migrate",
"--quiet",
"+",
"test",
"--only",
"integration"
] ++ args
{_output, exit_code} =
System.cmd("env", argv, into: IO.stream(:stdio, :line), cd: File.cwd!())
System.halt(exit_code)
end
end