[Jifty-commit] r1775 - jifty/trunk/lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Aug 7 12:57:08 EDT 2006


Author: nelhage
Date: Mon Aug  7 12:57:08 2006
New Revision: 1775

Modified:
   jifty/trunk/lib/Jifty/Test.pm

Log:
Fixing tests when using JDBI::Record::Memcached and setting things in the database from test scripts

Modified: jifty/trunk/lib/Jifty/Test.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Test.pm	(original)
+++ jifty/trunk/lib/Jifty/Test.pm	Mon Aug  7 12:57:08 2006
@@ -42,16 +42,24 @@
     $ENV{'JIFTY_TEST_CONFIG'} ||= $test_config;
     Jifty::Test->builder->{test_config} = $test_config;
     {
-        # Cache::Memcached stores things. And doesn't let them
-        # expire from the cache easily. This is fine in production,
-        # but during testing each test script needs its own namespace.
-        # we use the pid.
-
-        no warnings qw/redefine/;
-    
-        sub Jifty::Record::cache_key_prefix {
-            'jifty-test-' . $$;
-        }
+        # Cache::Memcached stores things. And doesn't let them expire
+        # from the cache easily. This is fine in production, but
+        # during testing each test script needs its own namespace.  we
+        # use the pid of the current process, and save it so the keys
+        # stays the same when we fork
+      {
+          package Jifty::Record;
+          no warnings qw/redefine/;
+
+          use vars qw/$cache_key_prefix/;
+
+          $cache_key_prefix = "jifty-test-$$";
+        
+          sub cache_key_prefix {
+              $Jifty::Record::cache_key_prefix;
+          }
+      }
+        
     }
     my $root = Jifty::Util->app_root;
 


More information about the Jifty-commit mailing list