Skip to content

Business intelligence made simple

Improved tests

Andrew Kane744361cfaa2b
diff --git a/Gemfile b/Gemfile
index a7c98c1b..6e5cef51 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,5 +6,5 @@ gem "rake"
gem "minitest", ">= 5"
gem "combustion"
gem "rails"
-gem "sqlite3"
+gem "pg"
gem "sprockets-rails"
diff --git a/test/charts_test.rb b/test/charts_test.rb
index 1af893d2..6c09afd7 100644
--- a/test/charts_test.rb
+++ b/test/charts_test.rb
@@ -1,10 +1,9 @@
require_relative "test_helper"
class ChartsTest < ActionDispatch::IntegrationTest
- # TODO fix casting
def test_line_chart
- run_query "SELECT date('now'), 1"
- # assert_match "LineChart", response.body
+ run_query "SELECT NOW(), 1"
+ assert_match "LineChart", response.body
end
def test_column_chart_format1
@@ -43,18 +42,18 @@ class ChartsTest < ActionDispatch::IntegrationTest
assert_match "map", response.body
end
- # TODO update
def test_target
- run_query "SELECT date('now'), 1, 2 AS target"
+ run_query "SELECT NOW(), 1, 2 AS target"
+ assert_match %{"name":"target"}, response.body
end
def test_cohort_analysis
- run_query "SELECT 1 AS user_id, date('now') AS conversion_time /* cohort analysis */"
- assert_match "This data source does not support cohort analysis", response.body
+ run_query "SELECT 1 AS user_id, NOW() AS conversion_time /* cohort analysis */", query_id: 1
+ assert_match "1 cohort", response.body
end
- def run_query(statement)
- post blazer.run_queries_path, params: {statement: statement, data_source: "main"}, xhr: true
+ def run_query(statement, query_id: nil)
+ post blazer.run_queries_path, params: {statement: statement, data_source: "main", query_id: query_id}, xhr: true
assert_response :success
end
end
diff --git a/test/controller_test.rb b/test/controller_test.rb
index 04f4bd78..7d26cc45 100644
--- a/test/controller_test.rb
+++ b/test/controller_test.rb
@@ -27,9 +27,10 @@ class ControllerTest < ActionDispatch::IntegrationTest
assert_equal query.data_source, audit.data_source
end
- # TODO switch to postgres and check table names
def test_tables
get blazer.tables_queries_path(data_source: "main")
assert_response :success
+ expected = ["ar_internal_metadata", "blazer_audits", "blazer_checks", "blazer_dashboard_queries", "blazer_dashboards", "blazer_queries", "schema_migrations"]
+ assert_equal expected, JSON.parse(response.body).map { |v| v["table"] }
end
end
diff --git a/test/internal/config/blazer.yml b/test/internal/config/blazer.yml
index 79706fb2..860859ce 100644
--- a/test/internal/config/blazer.yml
+++ b/test/internal/config/blazer.yml
@@ -2,7 +2,7 @@
data_sources:
main:
- url: "sqlite3::memory:"
+ url: postgres://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 b9781191..c6ae3c2a 100644
--- a/test/internal/config/database.yml
+++ b/test/internal/config/database.yml
@@ -1,3 +1,3 @@
test:
- adapter: sqlite3
- database: db/combustion_test.sqlite
+ adapter: postgresql
+ database: blazer_test