public
Description: All the extra stuff you could want for the Mack Framework.
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack-more.git
Finished tests for mack-data_mapper load_structure. [#67]
markbates (author)
Tue Aug 12 08:00:41 -0700 2008
commit  7a172b53d81204a5afe56ec67926eb5a3e9e362e
tree    af5e5cb4d510e839d1e72fe02f1b842da63e44de
parent  5e59164ee092bf48a7d906513e2cbd31a8a6e789
...
8
9
10
11
12
13
14
15
16
17
18
19
20
...
8
9
10
 
 
 
 
 
 
 
11
12
13
0
@@ -8,13 +8,6 @@ SET check_function_bodies = false;
0
 SET client_min_messages = warning;
0
 SET escape_string_warning = off;
0
 
0
---
0
--- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: -
0
---
0
-
0
-COMMENT ON SCHEMA public IS 'Standard public schema';
0
-
0
-
0
 SET search_path = public, pg_catalog;
0
 
0
 --
...
30
31
32
33
 
34
35
36
37
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
40
41
 
42
43
44
...
51
52
53
54
 
55
56
57
...
63
64
65
66
 
67
68
69
...
30
31
32
 
33
34
35
36
 
 
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 
86
87
88
89
...
96
97
98
 
99
100
101
102
...
108
109
110
 
111
112
113
114
0
@@ -30,15 +30,60 @@ describe Mack::Database do
0
     FileUtils.rm_rf(@sqlite3_dump)
0
   end
0
   
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
+    if auto_migrate
0
+      House.auto_migrate!(repis)
0
+      Cottage.auto_migrate!(repis)
0
+    end
0
+  end
0
+  
0
+  describe "load_structure" do
0
+    
0
+    describe "MySQL" do
0
+      
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
+      end
0
+      
0
+    end
0
+    
0
+    describe "Postgres" do
0
+      
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
+      end
0
+      
0
+    end
0
+    
0
+    describe "SQLite3" do
0
+      
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
+      end
0
+      
0
+    end
0
+    
0
   end
0
   
0
-  describe "structure_dump" do
0
+  describe "dump_structure" do
0
   
0
     describe "MySQL" do
0
     
0
@@ -51,7 +96,7 @@ describe Mack::Database do
0
       end
0
     
0
     end
0
-  
0
+      
0
     describe "Postgres" do
0
     
0
       it "should write a .sql that represents the db structure" do
0
@@ -63,7 +108,7 @@ describe Mack::Database do
0
       end
0
     
0
     end
0
-  
0
+      
0
     describe "SQLite3" do
0
     
0
       it "should write a .sql that represents the db structure" do
...
17
18
19
20
 
 
 
 
 
21
22
...
17
18
19
 
20
21
22
23
24
25
26
0
@@ -17,5 +17,9 @@ $genosaurus_output_directory = Mack.root
0
 require File.join(File.dirname(__FILE__), "..", "..", "mack-paths", "lib", "mack-paths")
0
 
0
 def fixture(name)
0
-  File.read(File.join(File.dirname(__FILE__), "fixtures", "#{name}.fixture"))
0
+  File.read(fixture_location(name))
0
+end
0
+
0
+def fixture_location(name)
0
+  File.join(File.dirname(__FILE__), "fixtures", "#{name}.fixture")
0
 end
0
\ No newline at end of file

Comments