Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an empty database spec #243

Merged
merged 2 commits into from
Aug 8, 2018
Merged

Conversation

bdunne
Copy link
Member

@bdunne bdunne commented Aug 7, 2018

An empty database (migrated form 0) should remain empty, only the schema itself should change.

Adding this as an automated code review to address #4 (comment)

@@ -0,0 +1,20 @@
describe "Empty Database" do
let(:connection) { ApplicationRecord.connection }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we use ActiveRecord::Base in the actual migrations. Should we use it here too?

@@ -0,0 +1,11 @@
describe "Empty Database" do
it "after migrated remains empty" do
counts = ApplicationRecord.connection.tables.each_with_object([]) do |t, array|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use ActiveRecord::Base.connection here? I know we use it in the migrations, but wasn't sure if we should in the specs as well.

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?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about negative row counts 😱 :trollface:

@bdunne bdunne force-pushed the empty_database_spec branch from b234145 to db33c1b Compare August 7, 2018 21:48
@miq-bot
Copy link
Member

miq-bot commented Aug 7, 2018

Checked commits bdunne/manageiq-schema@37a42d2~...db33c1b with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@carbonin carbonin self-assigned this Aug 8, 2018
@carbonin carbonin merged commit 3889554 into ManageIQ:master Aug 8, 2018
@carbonin carbonin added this to the Sprint 92 Ending Aug 13, 2018 milestone Aug 8, 2018
@bdunne bdunne deleted the empty_database_spec branch August 8, 2018 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants