-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for the migrator
- Loading branch information
1 parent
12d1dc7
commit cbeeaa5
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |