Skip to content

Business intelligence made simple

Improved tests for mysql2 and trilogy

Andrew Kanec59f48147972
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2ff9b7ff..4866e5d1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -35,5 +35,7 @@ jobs:
- uses: ankane/setup-mysql@v1
with:
database: blazer_test
+ - run: ADAPTER=mysql2 bundle exec rake test
- run: bundle exec rake test:mysql
+ - run: ADAPTER=trilogy bundle exec rake test
- run: MYSQL_ADAPTER=trilogy bundle exec rake test:mysql
diff --git a/test/cache_test.rb b/test/cache_test.rb
index 068b9fa9..3428ac09 100644
--- a/test/cache_test.rb
+++ b/test/cache_test.rb
@@ -24,6 +24,8 @@ class CacheTest < ActionDispatch::IntegrationTest
end
def test_slow_over_threshold
+ skip unless postgresql?
+
with_caching({"mode" => "slow", "slow_threshold" => 0.01}) do
run_query "SELECT pg_sleep(0.01)::text"
refute_match "Cached", response.body
diff --git a/test/charts_test.rb b/test/charts_test.rb
index 00af970f..066f8163 100644
--- a/test/charts_test.rb
+++ b/test/charts_test.rb
@@ -17,7 +17,7 @@ class ChartsTest < ActionDispatch::IntegrationTest
end
def test_column_chart_format2
- run_query "SELECT 'Label' AS label, 'Group' AS group, 1"
+ run_query "SELECT 'Label' AS label, 'Group' AS group2, 1"
assert_match "ColumnChart", response.body
assert_match %{"name":"Group"}, response.body
end
diff --git a/test/cohort_analysis_test.rb b/test/cohort_analysis_test.rb
index 6540b8da..7da3e592 100644
--- a/test/cohort_analysis_test.rb
+++ b/test/cohort_analysis_test.rb
@@ -1,18 +1,11 @@
require_relative "test_helper"
class CohortAnalysisTest < ActionDispatch::IntegrationTest
- def test_postgres
+ def test_works
run_query "SELECT 1 AS user_id, NOW() AS conversion_time /* cohort analysis */", query_id: 1
assert_match "1 cohort", response.body
end
- def test_mysql
- skip unless ENV["TEST_MYSQL"]
-
- run_query "SELECT 1 AS user_id, NOW() AS conversion_time /* cohort analysis */", query_id: 1, data_source: "mysql"
- assert_match "1 cohort", response.body
- end
-
def test_cohort_period_default
query = create_query(statement: "SELECT 1 AS user_id, NOW() AS conversion_time /* cohort analysis */")
get blazer.query_path(query)
diff --git a/test/internal/config/blazer.yml b/test/internal/config/blazer.yml
index 11ab6b39..bbfc556d 100644
--- a/test/internal/config/blazer.yml
+++ b/test/internal/config/blazer.yml
@@ -2,7 +2,7 @@
data_sources:
main:
- url: postgres://localhost/blazer_test
+ url: <%= ENV["ADAPTER"] || "postgresql" %>://localhost/blazer_test
# statement timeout, in seconds
# none by default
diff --git a/test/internal/config/database.yml b/test/internal/config/database.yml
index c6ae3c2a..98e22ad6 100644
--- a/test/internal/config/database.yml
+++ b/test/internal/config/database.yml
@@ -1,3 +1,3 @@
test:
- adapter: postgresql
+ adapter: <%= ENV["ADAPTER"] || "postgresql" %>
database: blazer_test
diff --git a/test/queries_test.rb b/test/queries_test.rb
index 890bfc08..5734b286 100644
--- a/test/queries_test.rb
+++ b/test/queries_test.rb
@@ -48,7 +48,8 @@ class QueriesTest < ActionDispatch::IntegrationTest
def test_tables
get blazer.tables_queries_path(data_source: "main")
assert_response :success
- tables = JSON.parse(response.body).map { |v| v["table"] }
+ tables = JSON.parse(response.body)
+ tables = tables.map { |v| v["table"] } if postgresql?
assert_includes tables, "blazer_queries"
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 8902fe72..7a257415 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -37,6 +37,10 @@ class ActionDispatch::IntegrationTest
def create_check(**attributes)
Blazer::Check.create!(schedule: "5 minutes", **attributes)
end
+
+ def postgresql?
+ ENV["ADAPTER"].nil?
+ end
end
require_relative "support/adapter_test"