[otrs-cvs] otrs/scripts/test AuthSession.t, 1.20, 1.21 Cache.t, 1.31, 1.32

"CVS commits notifications of OTRS.org" <[email protected]>
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/otrs/scripts/test
In directory lancelot:/tmp/cvs-serv29291/scripts/test

Modified Files:
	AuthSession.t Cache.t 
Log Message:
Added mechanism to detect backend modules automatically.

Author: mh

Index: AuthSession.t
===================================================================
RCS file: /home/cvs/otrs/scripts/test/AuthSession.t,v
retrieving revision 1.20
retrieving revision 1.21
diff -2 -u -d -r1.20 -r1.21
--- AuthSession.t	20 Nov 2012 16:05:16 -0000	1.20
+++ AuthSession.t	28 Nov 2012 10:59:53 -0000	1.21
@@ -20,5 +20,23 @@
 my $ConfigObject = Kernel::Config->new();
 
-for my $Module (qw(DB FS)) {
+# get home directory
+my $HomeDir = $ConfigObject->Get('Home');
+
+# get all avaliable backend modules
+my @BackendModuleFiles = $Self->{MainObject}->DirectoryRead(
+    Directory => $HomeDir . '/Kernel/System/AuthSession/',
+    Filter    => '*.pm',
+    Silent    => 1,
+);
+
+MODULEFILE:
+for my $ModuleFile (@BackendModuleFiles) {
+
+    next MODULEFILE if !$ModuleFile;
+
+    # extract module name
+    my ($Module) = $ModuleFile =~ m{ \/+ ([a-zA-Z0-9]+) \.pm $ }xms;
+
+    next MODULEFILE if !$Module;
 
     $ConfigObject->Set(

Author: mh

Index: Cache.t
===================================================================
RCS file: /home/cvs/otrs/scripts/test/Cache.t,v
retrieving revision 1.31
retrieving revision 1.32
diff -2 -u -d -r1.31 -r1.32
--- Cache.t	20 Nov 2012 16:05:23 -0000	1.31
+++ Cache.t	28 Nov 2012 10:59:53 -0000	1.32
@@ -20,8 +20,26 @@
 use Kernel::System::Cache;
 
+# use local Config object because it will be modified
 my $ConfigObject = Kernel::Config->new();
 
-MODULE:
-for my $Module (qw(FileStorable)) {
+# get home directory
+my $HomeDir = $ConfigObject->Get('Home');
+
+# get all avaliable backend modules
+my @BackendModuleFiles = $Self->{MainObject}->DirectoryRead(
+    Directory => $HomeDir . '/Kernel/System/Cache/',
+    Filter    => '*.pm',
+    Silent    => 1,
+);
+
+MODULEFILE:
+for my $ModuleFile (@BackendModuleFiles) {
+
+    next MODULEFILE if !$ModuleFile;
+
+    # extract module name
+    my ($Module) = $ModuleFile =~ m{ \/+ ([a-zA-Z0-9]+) \.pm $ }xms;
+
+    next MODULEFILE if !$Module;
 
     $ConfigObject->Set(
@@ -42,5 +60,5 @@
         );
 
-        next MODULE if !$CacheObject;
+        next MODULEFILE if !$CacheObject;
 
         # flush the cache to have a clear test enviroment
@@ -201,4 +219,6 @@
         );
 
+        my $TTLTimeStart = $Self->{TimeObject}->SystemTime();
+
         $CacheSet = $CacheObject->Set(
             Type  => 'CacheTest2',
@@ -210,5 +230,5 @@
         $Self->True(
             $CacheSet,
-            "#4 - $Module - $SubdirLevels - CacheSet(), TTL 2",
+            "#4 - $Module - $SubdirLevels - CacheSet(), TTL 4",
         );
 
@@ -218,15 +238,21 @@
         );
 
-        $Self->Is(
-            $CacheGet || '',
-            '9ßüß-カスタ1234',
-            "#4 - $Module - $SubdirLevels - CacheGet()",
-        );
-        $Self->True(
-            Encode::is_utf8($CacheGet) || '',
-            "#4 - $Module - $SubdirLevels - CacheGet() - Encode::is_utf8",
-        );
+        my $TTLTimeStop = $Self->{TimeObject}->SystemTime();
+        my $TTLTimeDiff = $TTLTimeStop - $TTLTimeStart;
 
-        sleep 5;
+        if ( $TTLTimeDiff <= 4 ) {
+
+            $Self->Is(
+                $CacheGet || '',
+                '9ßüß-カスタ1234',
+                "#4 - $Module - $SubdirLevels - CacheGet()",
+            );
+            $Self->True(
+                Encode::is_utf8($CacheGet) || '',
+                "#4 - $Module - $SubdirLevels - CacheGet() - Encode::is_utf8",
+            );
+        }
+
+        sleep( 6 - $TTLTimeDiff );
 
         $CacheGet = $CacheObject->Get(
@@ -237,5 +263,5 @@
         $Self->True(
             !$CacheGet || '',
-            "#4 - $Module - $SubdirLevels - CacheGet() - sleep4 - TTL of 2 expired",
+            "#4 - $Module - $SubdirLevels - CacheGet() - sleep 6 - TTL of 4 expired",
         );

---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.