Business intelligence made simple
Improved check tests
Andrew Kane2eac0116431f
diff --git a/Rakefile b/Rakefileindex 21f1938e..07b8e8eb 100644--- a/Rakefile+++ b/Rakefile@@ -5,4 +5,5 @@ task default: :testRake::TestTask.new do |t|t.libs << "test"t.pattern = "test/*_test.rb"+ t.warning = false # mail gemenddiff --git a/test/archive_test.rb b/test/archive_test.rbindex fc541ef8..29197533 100644--- a/test/archive_test.rb+++ b/test/archive_test.rb@@ -18,8 +18,4 @@ class ArchiveTest < ActionDispatch::IntegrationTestquery2.reloadassert_equal "active", query2.statusend-- def create_query- Blazer::Query.create!(statement: "SELECT 1", data_source: "main", status: "active")- endenddiff --git a/test/checks_test.rb b/test/checks_test.rbindex 09d1f5f8..86c4917d 100644--- a/test/checks_test.rb+++ b/test/checks_test.rb@@ -1,8 +1,30 @@require_relative "test_helper"class ChecksTest < ActionDispatch::IntegrationTest+ def setup+ Blazer::Check.delete_all+ Blazer::Query.delete_all+ end+def test_indexget blazer.checks_pathassert_response :successend++ def test_run+ query = create_query+ check = Blazer::Check.create!(query: query, schedule: "5 minutes", emails: "[email protected]")++ assert_emails 0 do+ Blazer.send_failing_checks+ end++ assert_emails 1 do+ Blazer.run_checks(schedule: "5 minutes")+ end++ assert_emails 1 do+ Blazer.send_failing_checks+ end+ endenddiff --git a/test/internal/config/blazer.yml b/test/internal/config/blazer.ymlindex d552dbc8..fae61aff 100644--- a/test/internal/config/blazer.yml+++ b/test/internal/config/blazer.yml@@ -55,7 +55,7 @@ audit: true# before_action_method: require_admin# email to send checks from-# from_email: [email protected]+from_email: [email protected]# webhook for Slack# slack_webhook_url:diff --git a/test/test_helper.rb b/test/test_helper.rbindex 5a8fc8a8..a51885d0 100644--- a/test/test_helper.rb+++ b/test/test_helper.rb@@ -7,7 +7,7 @@ require "minitest/pride"logger = ActiveSupport::Logger.new(ENV["VERBOSE"] ? STDERR : nil)Combustion.path = "test/internal"-Combustion.initialize! :active_record, :action_controller, :sprockets do+Combustion.initialize! :active_record, :action_controller, :action_mailer, :sprockets doconfig.action_controller.logger = loggerconfig.active_record.logger = loggerend@@ -21,4 +21,8 @@ class ActionDispatch::IntegrationTestpost blazer.run_queries_path, params: {statement: statement, data_source: "main"}.merge(params), xhr: trueassert_response :successend++ def create_query+ Blazer::Query.create!(statement: "SELECT 1", data_source: "main", status: "active")+ endend