0
@@ -30,15 +30,60 @@ describe Mack::Database do
0
FileUtils.rm_rf(@sqlite3_dump)
0
- def create_structure_dump_test_db(repis, path
)
0
+ def create_structure_dump_test_db(repis, path
, auto_migrate = true)
0
DataMapper.setup(repis, path)
0
Mack::Database.drop(Mack.env, repis)
0
Mack::Database.create(Mack.env, repis)
0
- House.auto_migrate!(repis)
0
- Cottage.auto_migrate!(repis)
0
+ House.auto_migrate!(repis)
0
+ Cottage.auto_migrate!(repis)
0
+ describe "load_structure" do
0
+ it "should reconstructe a db from a .sql file" do
0
+ create_structure_dump_test_db(:test_mysql, "mysql://root@localhost/structure_dump_test", false)
0
+ Cottage.should_not be_storage_exists(:test_mysql)
0
+ House.should_not be_storage_exists(:test_mysql)
0
+ Mack::Database.load_structure(fixture_location("test_test_mysql_schema_structure.sql"), Mack.env, :test_mysql)
0
+ Cottage.should be_storage_exists(:test_mysql)
0
+ House.should be_storage_exists(:test_mysql)
0
+ describe "Postgres" do
0
+ it "should reconstructe a db from a .sql file" do
0
+ create_structure_dump_test_db(:test_postgres, "postgres://ruby:password@localhost/structure_dump_test1", false)
0
+ Cottage.should_not be_storage_exists(:test_postgres)
0
+ House.should_not be_storage_exists(:test_postgres)
0
+ Mack::Database.load_structure(fixture_location("test_test_postgres_schema_structure.sql"), Mack.env, :test_postgres)
0
+ Cottage.should be_storage_exists(:test_postgres)
0
+ House.should be_storage_exists(:test_postgres)
0
+ it "should reconstructe a db from a .sql file" do
0
+ create_structure_dump_test_db(:test_sqlite3, "sqlite3://#{File.join(Mack.root, "db", "structure_dump_test1.db")}", false)
0
+ Cottage.should_not be_storage_exists(:test_sqlite3)
0
+ House.should_not be_storage_exists(:test_sqlite3)
0
+ Mack::Database.load_structure(fixture_location("test_test_sqlite3_schema_structure.sql"), Mack.env, :test_sqlite3)
0
+ Cottage.should be_storage_exists(:test_sqlite3)
0
+ House.should be_storage_exists(:test_sqlite3)
0
- describe "
structure_dump" do
0
+ describe "
dump_structure" do
0
@@ -51,7 +96,7 @@ describe Mack::Database do
0
it "should write a .sql that represents the db structure" do
0
@@ -63,7 +108,7 @@ describe Mack::Database do
0
it "should write a .sql that represents the db structure" do