Business intelligence made simple
Improved tests for mysql2 and trilogy
Andrew Kanec59f48147972
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 2ff9b7ff..4866e5d1 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -35,5 +35,7 @@ jobs:- uses: ankane/setup-mysql@v1with: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:mysqldiff --git a/test/cache_test.rb b/test/cache_test.rbindex 068b9fa9..3428ac09 100644--- a/test/cache_test.rb+++ b/test/cache_test.rb@@ -24,6 +24,8 @@ class CacheTest < ActionDispatch::IntegrationTestenddef test_slow_over_threshold+ skip unless postgresql?+with_caching({"mode" => "slow", "slow_threshold" => 0.01}) dorun_query "SELECT pg_sleep(0.01)::text"refute_match "Cached", response.bodydiff --git a/test/charts_test.rb b/test/charts_test.rbindex 00af970f..066f8163 100644--- a/test/charts_test.rb+++ b/test/charts_test.rb@@ -17,7 +17,7 @@ class ChartsTest < ActionDispatch::IntegrationTestenddef 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.bodyassert_match %{"name":"Group"}, response.bodyenddiff --git a/test/cohort_analysis_test.rb b/test/cohort_analysis_test.rbindex 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_worksrun_query "SELECT 1 AS user_id, NOW() AS conversion_time /* cohort analysis */", query_id: 1assert_match "1 cohort", response.bodyend- 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_defaultquery = 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.ymlindex 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 defaultdiff --git a/test/internal/config/database.yml b/test/internal/config/database.ymlindex 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_testdiff --git a/test/queries_test.rb b/test/queries_test.rbindex 890bfc08..5734b286 100644--- a/test/queries_test.rb+++ b/test/queries_test.rb@@ -48,7 +48,8 @@ class QueriesTest < ActionDispatch::IntegrationTestdef test_tablesget 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"enddiff --git a/test/test_helper.rb b/test/test_helper.rbindex 8902fe72..7a257415 100644--- a/test/test_helper.rb+++ b/test/test_helper.rb@@ -37,6 +37,10 @@ class ActionDispatch::IntegrationTestdef create_check(**attributes)Blazer::Check.create!(schedule: "5 minutes", **attributes)end++ def postgresql?+ ENV["ADAPTER"].nil?+ endendrequire_relative "support/adapter_test"