Skip to content

Commit

Permalink
Add integration tests for the migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed May 11, 2010
1 parent 12d1dc7 commit cbeeaa5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions spec/integration/migrator_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require File.join(File.dirname(__FILE__), 'spec_helper.rb')

Sequel.extension :migration
describe Sequel::Migrator do
before do
@db = INTEGRATION_DB
@m = Sequel::Migrator
@dir = 'spec/files/integer_migrations'
end
after do
[:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.drop_table(n) rescue nil}
end

specify "should be able to migrate up and down all the way successfully" do
@m.apply(@db, @dir)
[:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_true}
@db[:schema_info].get(:version).should == 3
@m.apply(@db, @dir, 0)
[:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_false}
@db[:schema_info].get(:version).should == 0
end

specify "should be able to migrate up and down to specific versions successfully" do
@m.apply(@db, @dir, 2)
[:schema_info, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should be_true}
@db.table_exists?(:sm3333).should be_false
@db[:schema_info].get(:version).should == 2
@m.apply(@db, @dir, 1)
[:sm2222, :sm3333].each{|n| @db.table_exists?(n).should be_false}
@db.table_exists?(:sm1111).should be_true
@db[:schema_info].get(:version).should == 1
end
end

0 comments on commit cbeeaa5

Please sign in to comment.