Skip to content

Commit

Permalink
Add a test expecting *_id columns to be bigint type
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunne committed Aug 9, 2018
1 parent ed03d47 commit 0f34e78
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/automated_review/id_columns_are_bigint_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
describe "*_id columns" do
it "should be type bigint" do
exceptions_list = [
"authentications.ldap_id",
"authentications.rhsm_pool_id",
"cloud_networks.provider_segmentation_id",
"container_volumes.common_volume_id",
"miq_queue.task_id", # <--WAT? Expected miq_queue.task_id to be type 'bigint', got: character varying
"network_ports.binding_host_id",
"scan_histories.task_id", # <--WAT?
"sessions.session_id"
].freeze

ActiveRecord::Base.connection.tables.each do |table|
next if ManageIQ::Schema::SYSTEM_TABLES.include?(table)
DatabaseHelper.columns_for_table(table).each do |column|
next unless column.name.end_with?("_id")
next if "#{table}.#{column.name}".in?(exceptions_list)
expect(column.sql_type).to eq("bigint"), "Expected #{table}.#{column.name} to be type 'bigint', got: #{column.sql_type}"
end
end
end
end

0 comments on commit 0f34e78

Please sign in to comment.