Add TimescaleDB integration tests
davydog187 opened this issue · 1 comments
davydog187 commented
From @akoutmos in slack
akoutmos - We should also add an issue for integration tests in CI
the assert_sql assertion is good for unit testing, but would be great to get some real TimescaleDB integration tests to validate that the functions not only produce expected SQL, but also return the expected results
💯 that we should have integration tests here. The main issue will be finding a way to have ecto migrations without shipping them in the library. We may just need a publishing script that wipes the priv
directory when we do mix hex.publish
davydog187 commented
I just tried writing some tests for the migration functions, and realizing that we can only test these via integration tests.
defmodule Timescale.MigrationTest do
use Timescale.SQLCase
import Timescale.Migration
alias TimescaleApp.Table
test "add_compression_policy/2 generates a valid query" do
assert_sql(
add_compression_policy(:my_table, "5 minutes"),
~s[SELECT last(m0."a", m0."timestamp") FROM "my_table" AS m0]
)
end
end
will yield
1) test add_compression_policy/2 generates a valid query (Timescale.MigrationTest)
test/timescale/migration_test.exs:8
** (RuntimeError) could not find migration runner process for #PID<0.326.0>
code: add_compression_policy(:my_table, "5 minutes"),
stacktrace:
(ecto_sql 3.8.3) lib/ecto/migration/runner.ex:304: Ecto.Migration.Runner.runner/0
(ecto_sql 3.8.3) lib/ecto/migration/runner.ex:129: Ecto.Migration.Runner.execute/1
test/timescale/migration_test.exs:10: (test)