-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathtest_helper.exs
More file actions
40 lines (29 loc) · 1.19 KB
/
test_helper.exs
File metadata and controls
40 lines (29 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Logger.configure(level: :info)
Calendar.put_time_zone_database(Tz.TimeZoneDatabase)
Code.require_file("test/support/ecto_schemas.exs")
Code.require_file("test/support/schemas.exs")
alias Ecto.Integration.TestRepo
Application.put_env(:ecto_ch, TestRepo,
adapter: Ecto.Adapters.ClickHouse,
database: "ecto_ch_test",
show_sensitive_data_on_connection_error: true
)
clickhouse_available? =
case :httpc.request(:get, {~c"http://localhost:8123/ping", []}, [], []) do
{:ok, {{_version, _status = 200, _reason}, _headers, ~c"Ok.\n"}} ->
true
{:error, {:failed_connect, [{:to_address, _to_address}, {:inet, [:inet], :econnrefused}]}} ->
false
end
unless clickhouse_available? do
Mix.shell().error("""
ClickHouse is not detected! Please start the local container with the following command:
docker compose up -d clickhouse
""")
end
{:ok, _} = Ecto.Adapters.ClickHouse.ensure_all_started(TestRepo.config(), :temporary)
_ = Ecto.Adapters.ClickHouse.storage_down(TestRepo.config())
:ok = Ecto.Adapters.ClickHouse.storage_up(TestRepo.config())
{:ok, _} = TestRepo.start_link()
:ok = Ecto.Migrator.up(TestRepo, 0, EctoClickHouse.Integration.Migration, log: false)
ExUnit.start()