From 7b1d5e17b143427ad98a805f7cc3f22aed844ed1 Mon Sep 17 00:00:00 2001 From: Brandon Dunne Date: Tue, 7 Aug 2018 14:52:58 -0400 Subject: [PATCH] Add a test to ensure that an empty database remains empty Only the schema itself should change --- spec/automated_review/empty_database_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 spec/automated_review/empty_database_spec.rb diff --git a/spec/automated_review/empty_database_spec.rb b/spec/automated_review/empty_database_spec.rb new file mode 100644 index 000000000..5de49e2ac --- /dev/null +++ b/spec/automated_review/empty_database_spec.rb @@ -0,0 +1,11 @@ +describe "Empty Database" do + it "after migrated remains empty" do + counts = ApplicationRecord.connection.tables.each_with_object([]) do |t, array| + next if ManageIQ::Schema::SYSTEM_TABLES.include?(t) + count = ApplicationRecord.connection.execute("SELECT COUNT(*) FROM #{t};").getvalue(0, 0) + array << "#{t}: #{count}" if count.positive? + end + + expect(counts.size).to eq(0), "Records were found in the following tables:\n#{counts.join("\n")}" + end +end