Skip to content

Commit

Permalink
test: updated tests for changing migration strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Oct 16, 2017
1 parent 69b5a20 commit 8293601
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion db/test/change_migration_strategy/before/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem "rake", "~>12.0"
gem "pact_broker", git: "https://github.com/pact-foundation/pact_broker.git", ref: "a963fce89c44d89d00899956f218a62fa2b786c7"
gem "pact_broker", git: "https://github.com/pact-foundation/pact_broker.git", ref: "8783ef83730969f3fce0034f36c7cf4652dc8733"
gem "sqlite3", "~>1.3"
gem "pg"
18 changes: 9 additions & 9 deletions spec/migrations/change_migration_strategy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
FileUtils.rm_rf DATABASE_PATH
end

it "uses pact_broker v 2.0.5" do
it "uses pact_broker v 2.6.0" do
Dir.chdir(TEST_DIR) do
Bundler.with_clean_env do
`bundle install --gemfile before/Gemfile`
expect(`BUNDLE_GEMFILE=before/Gemfile bundle exec rake pact_broker:version`.strip).to eq '2.0.5'
expect(`BUNDLE_GEMFILE=before/Gemfile bundle exec rake pact_broker:version`.strip).to eq '2.6.0'
end
end
end

it "migrates using integer migrations using pact_broker v2.0.5" do
it "migrates using integer migrations using pact_broker v2.6.0" do
Dir.chdir(TEST_DIR) do
Bundler.with_clean_env do
output = `BUNDLE_GEMFILE=before/Gemfile bundle exec rake pact_broker:db:migrate[35]`
Expand All @@ -52,20 +52,20 @@
expect(@db.table_exists?(:schema_migrations)).to be false
end

it "migrates using timestamp migrations using pact_broker > 2.0.5" do
it "migrates using timestamp migrations using pact_broker > 2.6.0" do
Dir.chdir(TEST_DIR) do
output = `bundle exec rake pact_broker:db:migrate`
puts output
output = `bundle exec rake pact_broker:db:version`
puts output
expect(output.strip).to eq "36"
expect(output.strip).to eq "47"
end
end

it "uses the schema_migrations table after v2.0.5" do
it "uses the schema_migrations table after v2.6.0" do
expect(@db.table_exists?(:schema_migrations)).to be true
migrations_count = Dir.glob("db/migrations/**.*").select{ |f| f =~ /\/\d+/ }.count
expect(migrations_count).to be >= 36
expect(migrations_count).to be >= 47
expect(@db[:schema_migrations].count).to eq migrations_count
expect(@db[:schema_migrations].order(:filename).first[:filename]).to eq '000001_create_pacticipant_table.rb'
end
Expand All @@ -76,11 +76,11 @@

it "allows rollback" do
Dir.chdir(TEST_DIR) do
output = `bundle exec rake pact_broker:db:migrate[34]`
output = `bundle exec rake pact_broker:db:migrate[45]`
puts output
output = `bundle exec rake pact_broker:db:version`
puts output
expect(output.strip).to eq "34"
expect(output.strip).to eq "45"
end
end
end

0 comments on commit 8293601

Please sign in to comment.