Skip to content

Business intelligence made simple

Improved adapter tests [skip ci]

Andrew Kane829b0c3c6b9a
diff --git a/test/adapters/cassandra_test.rb b/test/adapters/cassandra_test.rb
index 7223cd6c..4a7a39e1 100644
--- a/test/adapters/cassandra_test.rb
+++ b/test/adapters/cassandra_test.rb
@@ -8,6 +8,7 @@ class CassandraTest < ActionDispatch::IntegrationTest
end
def setup
+ super
@@once ||= begin
require "cassandra"
cluster = Cassandra.cluster(hosts: ["localhost"])
diff --git a/test/adapters/influxdb_test.rb b/test/adapters/influxdb_test.rb
index 72b1103b..922089b2 100644
--- a/test/adapters/influxdb_test.rb
+++ b/test/adapters/influxdb_test.rb
@@ -8,6 +8,7 @@ class InfluxdbTest < ActionDispatch::IntegrationTest
end
def setup
+ super
@@once ||= begin
client = InfluxDB::Client.new(url: "http://localhost:8086/blazer_test")
client.delete_series("items")
diff --git a/test/adapters/postgresql_test.rb b/test/adapters/postgresql_test.rb
index ca27078e..24c030fa 100644
--- a/test/adapters/postgresql_test.rb
+++ b/test/adapters/postgresql_test.rb
@@ -7,6 +7,15 @@ class PostgresqlTest < ActionDispatch::IntegrationTest
"postgresql"
end
+ def setup
+ super
+ @@once ||= begin
+ execute "CREATE VIEW users_view AS SELECT * FROM users"
+ execute "CREATE MATERIALIZED VIEW users_matview AS SELECT * FROM users"
+ true
+ end
+ end
+
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
@@ -85,7 +94,6 @@ class PostgresqlTest < ActionDispatch::IntegrationTest
end
def test_tables_method
- setup_views
tables = ds.tables.map { |v| v[:table] }
assert_includes tables, "users"
assert_includes tables, "users_view"
@@ -94,7 +102,6 @@ class PostgresqlTest < ActionDispatch::IntegrationTest
end
def test_schema_method
- setup_views
schema = ds.schema
tables = schema.map { |v| v[:table] }
assert_includes tables, "users"
@@ -102,14 +109,4 @@ class PostgresqlTest < ActionDispatch::IntegrationTest
# TODO add
refute_includes tables, "users_matview"
end
-
- private
-
- def setup_views
- @@setup_views ||= begin
- execute "CREATE VIEW users_view AS SELECT * FROM users"
- execute "CREATE MATERIALIZED VIEW users_matview AS SELECT * FROM users"
- true
- end
- end
end
diff --git a/test/adapters/sqlite_test.rb b/test/adapters/sqlite_test.rb
index 7c900e3b..ad6398e9 100644
--- a/test/adapters/sqlite_test.rb
+++ b/test/adapters/sqlite_test.rb
@@ -7,6 +7,15 @@ class SqliteTest < ActionDispatch::IntegrationTest
"sqlite"
end
+ def setup
+ super
+ @@once ||= begin
+ execute "CREATE TABLE users (id integer)"
+ execute "CREATE VIEW users_view AS SELECT * FROM users"
+ true
+ end
+ end
+
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
@@ -53,27 +62,15 @@ class SqliteTest < ActionDispatch::IntegrationTest
def test_tables_method
- setup_tables
tables = ds.tables
assert_includes tables, "users"
assert_includes tables, "users_view"
end
def test_schema_method
- setup_tables
schema = ds.schema
tables = schema.map { |v| v[:table] }
assert_includes tables, "users"
assert_includes tables, "users_view"
end
-
- private
-
- def setup_tables
- @@setup_tables ||= begin
- execute "CREATE TABLE users (id integer)"
- execute "CREATE VIEW users_view AS SELECT * FROM users"
- true
- end
- end
end