[Jifty-commit] r3299 - in jifty/branches/autoversioning: .

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu May 24 02:26:42 EDT 2007


Author: jesse
Date: Thu May 24 02:26:42 2007
New Revision: 3299

Modified:
   jifty/branches/autoversioning/   (props changed)
   jifty/branches/autoversioning/t/TestApp/t/16-autoversioning.t

Log:
 r57085 at pinglin:  jesse | 2007-05-24 02:26:28 -0400
 * testing table and column add and del


Modified: jifty/branches/autoversioning/t/TestApp/t/16-autoversioning.t
==============================================================================
--- jifty/branches/autoversioning/t/TestApp/t/16-autoversioning.t	(original)
+++ jifty/branches/autoversioning/t/TestApp/t/16-autoversioning.t	Thu May 24 02:26:42 2007
@@ -5,14 +5,15 @@
 
 =head1 DESCRIPTION
 
-This is a template for your own tests. Copy it and modify it.
+Right now, this test script only tests that our schema diffing tool picks up the right things.
+Next we'll want to try to apply the changes
 
 =cut
 
 use lib 't/lib';
 use Jifty::SubTest;
 
-use Jifty::Test tests => 1;
+use Jifty::Test tests => 28;
 
 ok(1, "Loaded the test script");
 
@@ -38,8 +39,9 @@
 
 
 # remove a column, make sure it is picked up
-delete $serialized->{'TestApp::Model::User'}->{columns}->{tasty};
 {
+ $serialized = $schema->serialize_current_schema;
+delete $serialized->{'TestApp::Model::User'}->{columns}->{tasty};
     my ( $add_tables, $add_columns, $remove_tables, $remove_columns )
             = $schema->compute_schema_diffs( $stored, $serialized);
 
@@ -51,12 +53,56 @@
 }
 
 
+# remove a table, make sure it is picked up
+{
+
+ $serialized = $schema->serialize_current_schema;
+delete $serialized->{'TestApp::Model::User'};
+    my ( $add_tables, $add_columns, $remove_tables, $remove_columns )
+            = $schema->compute_schema_diffs( $stored, $serialized);
+
+is_deeply($add_tables, {});
+is_deeply([keys %$remove_tables], ['TestApp::Model::User']);
+is_deeply($remove_columns, {});
+is_deeply($add_columns,{});
+}
 
 
-# remove a table, make sure it is picked up
 # add a column, make sure it is picked up
+{
+ $serialized = $schema->serialize_current_schema;
+
+$serialized->{'TestApp::Model::User'}->{columns}->{speedy} = $serialized->{'TestApp::Model::User'}->{columns}->{tasty};
+$serialized->{'TestApp::Model::User'}->{columns}->{speedy}->{name} = 'speedy';
+    my ( $add_tables, $add_columns, $remove_tables, $remove_columns )
+            = $schema->compute_schema_diffs( $stored, $serialized);
+
+is_deeply($add_tables, {});
+is_deeply($remove_tables, {});
+is_deeply($remove_columns, {});
+is_deeply([keys %$add_columns], ['TestApp::Model::User' ]);
+is_deeply($add_columns->{'TestApp::Model::User'}[0]->{'name'}, 'speedy');
+}
+
+
+
+
 # add a table, make sure it is picked up
 
+{
+ $serialized = $schema->serialize_current_schema;
+$serialized->{'TestApp::Model::Foobar'} = $serialized->{'TestApp::Model::User'};
+$serialized->{'TestApp::Model::Foobar'}->{'class'} = "TestApp::Model::Foobar";
+$serialized->{'TestApp::Model::Foobar'}->{'table'} = "foobar";
+
+    my ( $add_tables, $add_columns, $remove_tables, $remove_columns )
+            = $schema->compute_schema_diffs( $stored, $serialized);
+
+is_deeply($remove_tables, {});
+is_deeply([keys %$add_tables], ['TestApp::Model::Foobar']);
+is_deeply($remove_columns, {});
+is_deeply($add_columns,{});
+}
 
 1;
 


More information about the Jifty-commit mailing list