Skip to content

Business intelligence made simple

Improved adapter tests [skip ci]

Andrew Kanefd75ffc9dab5
diff --git a/test/adapters/postgresql_test.rb b/test/adapters/postgresql_test.rb
index 24c030fa..992f2eec 100644
--- a/test/adapters/postgresql_test.rb
+++ b/test/adapters/postgresql_test.rb
@@ -16,6 +16,30 @@ class PostgresqlTest < ActionDispatch::IntegrationTest
end
end
+ def test_result
+ result = ds.run_statement("SELECT 'world' AS hello")
+ assert_equal [["world"]], result.rows
+ assert_equal ["hello"], result.columns
+ assert_equal ["string"], result.column_types
+ end
+
+ def test_tables_method
+ tables = ds.tables.map { |v| v[:table] }
+ assert_includes tables, "users"
+ assert_includes tables, "users_view"
+ # TODO add
+ refute_includes tables, "users_matview"
+ end
+
+ def test_schema_method
+ schema = ds.schema
+ tables = schema.map { |v| v[:table] }
+ assert_includes tables, "users"
+ assert_includes tables, "users_view"
+ # TODO add
+ refute_includes tables, "users_matview"
+ end
+
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
@@ -92,21 +116,4 @@ class PostgresqlTest < ActionDispatch::IntegrationTest
def test_jsonb_output
assert_result [{"jsonb" => '{"hello": "world"}'}], %!SELECT '{"hello": "world"}'::jsonb!
end
-
- def test_tables_method
- tables = ds.tables.map { |v| v[:table] }
- assert_includes tables, "users"
- assert_includes tables, "users_view"
- # TODO add
- refute_includes tables, "users_matview"
- end
-
- def test_schema_method
- schema = ds.schema
- tables = schema.map { |v| v[:table] }
- assert_includes tables, "users"
- assert_includes tables, "users_view"
- # TODO add
- refute_includes tables, "users_matview"
- end
end
diff --git a/test/adapters/sqlite_test.rb b/test/adapters/sqlite_test.rb
index f7d0217c..893fbc21 100644
--- a/test/adapters/sqlite_test.rb
+++ b/test/adapters/sqlite_test.rb
@@ -16,6 +16,26 @@ class SqliteTest < ActionDispatch::IntegrationTest
end
end
+ def test_result
+ result = ds.run_statement("SELECT 'world' AS hello")
+ assert_equal [["world"]], result.rows
+ assert_equal ["hello"], result.columns
+ assert_equal ["string"], result.column_types
+ end
+
+ def test_tables_method
+ tables = ds.tables
+ assert_includes tables, "users"
+ assert_includes tables, "users_view"
+ end
+
+ def test_schema_method
+ schema = ds.schema
+ tables = schema.map { |v| v[:table] }
+ assert_includes tables, "users"
+ assert_includes tables, "users_view"
+ end
+
def test_run
assert_result [{"hello" => "world"}], "SELECT 'world' AS hello"
end
@@ -59,17 +79,4 @@ class SqliteTest < ActionDispatch::IntegrationTest
def test_multiple_variables
assert_result [{"c1" => "one", "c2" => "two", "c3" => "one"}], "SELECT {var} AS c1, {var2} AS c2, {var} AS c3", var: "one", var2: "two"
end
-
- def test_tables_method
- tables = ds.tables
- assert_includes tables, "users"
- assert_includes tables, "users_view"
- end
-
- def test_schema_method
- schema = ds.schema
- tables = schema.map { |v| v[:table] }
- assert_includes tables, "users"
- assert_includes tables, "users_view"
- end
end