[Koha-patches] [PATCH] Bug 5477 - Fix test cases that require database access

Robin Sheat robin at catalyst.net.nz
Thu Dec 9 02:08:59 CET 2010


This moves the DB-requiring tests out of the way, with the exception of
00-load.t which is used by the git hooks. For it, it makes it skip
loading problematic modules. This allows 'make test' to complete successfully
without a database configured, wich is a required part of making packages.

This has been tested against the v3.02.01 tag and the master branch.
---
 t/00-load.t                           |   15 ++++++++++++---
 t/Auth_with_cas.t                     |   14 --------------
 t/External_BakerTaylor.t              |   14 --------------
 t/Reports_Guided.t                    |   14 --------------
 t/Service.t                           |   14 --------------
 t/Tags.t                              |   14 --------------
 t/UploadedFile.t                      |   14 --------------
 t/VirtualShelves_Page.t               |   14 --------------
 t/db_dependent/Auth_with_cas.t        |   14 ++++++++++++++
 t/db_dependent/External_BakerTaylor.t |   14 ++++++++++++++
 t/db_dependent/Reports_Guided.t       |   14 ++++++++++++++
 t/db_dependent/Service.t              |   14 ++++++++++++++
 t/db_dependent/Tags.t                 |   14 ++++++++++++++
 t/db_dependent/UploadedFile.t         |   14 ++++++++++++++
 t/db_dependent/VirtualShelves_Page.t  |   14 ++++++++++++++
 15 files changed, 110 insertions(+), 101 deletions(-)
 delete mode 100755 t/Auth_with_cas.t
 delete mode 100755 t/External_BakerTaylor.t
 delete mode 100755 t/Reports_Guided.t
 delete mode 100755 t/Service.t
 delete mode 100755 t/Tags.t
 delete mode 100755 t/UploadedFile.t
 delete mode 100755 t/VirtualShelves_Page.t
 create mode 100755 t/db_dependent/Auth_with_cas.t
 create mode 100755 t/db_dependent/External_BakerTaylor.t
 create mode 100755 t/db_dependent/Reports_Guided.t
 create mode 100755 t/db_dependent/Service.t
 create mode 100755 t/db_dependent/Tags.t
 create mode 100755 t/db_dependent/UploadedFile.t
 create mode 100755 t/db_dependent/VirtualShelves_Page.t

diff --git a/t/00-load.t b/t/00-load.t
index b5c7181..5b6e60f 100644
--- a/t/00-load.t
+++ b/t/00-load.t
@@ -13,12 +13,21 @@ find({
     wanted => sub {
         my $m = $_;
 	    return unless $m =~ s/[.]pm$//;
+	    $m =~ s{^.*/C4/}{C4/};	
+	    $m =~ s{/}{::}g;
 	    return if $m =~ /Auth_with_ldap/; # Dont test this, it will fail on use
 	    return if $m =~ /Cache/; # Cache modules are a WIP, add the tests back when we are using them more
 	    return if $m =~ /SIP/; # SIP modules will not load clean
-	    $m =~ s{^.*/C4/}{C4/};	
-	    $m =~ s{/}{::}g;
-	    use_ok($m) || BAIL_OUT("***** PROBLEMS LOADING FILE '$m'");
+	    return if $m =~ /C4::VirtualShelves$/; # Requires a DB
+	    return if $m =~ /C4::Auth$/; # DB
+	    return if $m =~ /C4::Tags$/; # DB
+	    return if $m =~ /C4::Service/; # DB
+	    return if $m =~ /C4::Auth_with_cas/; # DB
+	    return if $m =~ /C4::BackgroundJob/; # DB
+	    return if $m =~ /C4::UploadedFile/; # DB
+	    return if $m =~ /C4::Reports::Guided/; # DB
+	    return if $m =~ /C4::VirtualShelves::Page/; # DB
+        use_ok($m) || BAIL_OUT("***** PROBLEMS LOADING FILE '$m'");
     },
 }, $lib);
 done_testing();
diff --git a/t/Auth_with_cas.t b/t/Auth_with_cas.t
deleted file mode 100755
index 77dd21f..0000000
--- a/t/Auth_with_cas.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-#
-# This Koha test module is a stub!  
-# Add more tests here!!!
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-
-BEGIN {
-        use_ok('C4::Auth_with_cas');
-}
-
diff --git a/t/External_BakerTaylor.t b/t/External_BakerTaylor.t
deleted file mode 100755
index fdccaee..0000000
--- a/t/External_BakerTaylor.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-#
-# This Koha test module is a stub!  
-# Add more tests here!!!
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-
-BEGIN {
-        use_ok('C4::External::BakerTaylor');
-}
-
diff --git a/t/Reports_Guided.t b/t/Reports_Guided.t
deleted file mode 100755
index 0b0cda6..0000000
--- a/t/Reports_Guided.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-#
-# This Koha test module is a stub!  
-# Add more tests here!!!
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-
-BEGIN {
-        use_ok('C4::Reports::Guided');
-}
-
diff --git a/t/Service.t b/t/Service.t
deleted file mode 100755
index 497cc1b..0000000
--- a/t/Service.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-#
-# This Koha test module is a stub!  
-# Add more tests here!!!
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-
-BEGIN {
-        use_ok('C4::Service');
-}
-
diff --git a/t/Tags.t b/t/Tags.t
deleted file mode 100755
index 83b3c9b..0000000
--- a/t/Tags.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-#
-# This Koha test module is a stub!  
-# Add more tests here!!!
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-
-BEGIN {
-        use_ok('C4::Tags');
-}
-
diff --git a/t/UploadedFile.t b/t/UploadedFile.t
deleted file mode 100755
index dd01e1b..0000000
--- a/t/UploadedFile.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-#
-# This Koha test module is a stub!  
-# Add more tests here!!!
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-
-BEGIN {
-        use_ok('C4::UploadedFile');
-}
-
diff --git a/t/VirtualShelves_Page.t b/t/VirtualShelves_Page.t
deleted file mode 100755
index 236d147..0000000
--- a/t/VirtualShelves_Page.t
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/perl
-#
-# This Koha test module is a stub!  
-# Add more tests here!!!
-
-use strict;
-use warnings;
-
-use Test::More tests => 1;
-
-BEGIN {
-        use_ok('C4::VirtualShelves::Page');
-}
-
diff --git a/t/db_dependent/Auth_with_cas.t b/t/db_dependent/Auth_with_cas.t
new file mode 100755
index 0000000..77dd21f
--- /dev/null
+++ b/t/db_dependent/Auth_with_cas.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+#
+# This Koha test module is a stub!  
+# Add more tests here!!!
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+BEGIN {
+        use_ok('C4::Auth_with_cas');
+}
+
diff --git a/t/db_dependent/External_BakerTaylor.t b/t/db_dependent/External_BakerTaylor.t
new file mode 100755
index 0000000..fdccaee
--- /dev/null
+++ b/t/db_dependent/External_BakerTaylor.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+#
+# This Koha test module is a stub!  
+# Add more tests here!!!
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+BEGIN {
+        use_ok('C4::External::BakerTaylor');
+}
+
diff --git a/t/db_dependent/Reports_Guided.t b/t/db_dependent/Reports_Guided.t
new file mode 100755
index 0000000..0b0cda6
--- /dev/null
+++ b/t/db_dependent/Reports_Guided.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+#
+# This Koha test module is a stub!  
+# Add more tests here!!!
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+BEGIN {
+        use_ok('C4::Reports::Guided');
+}
+
diff --git a/t/db_dependent/Service.t b/t/db_dependent/Service.t
new file mode 100755
index 0000000..497cc1b
--- /dev/null
+++ b/t/db_dependent/Service.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+#
+# This Koha test module is a stub!  
+# Add more tests here!!!
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+BEGIN {
+        use_ok('C4::Service');
+}
+
diff --git a/t/db_dependent/Tags.t b/t/db_dependent/Tags.t
new file mode 100755
index 0000000..83b3c9b
--- /dev/null
+++ b/t/db_dependent/Tags.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+#
+# This Koha test module is a stub!  
+# Add more tests here!!!
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+BEGIN {
+        use_ok('C4::Tags');
+}
+
diff --git a/t/db_dependent/UploadedFile.t b/t/db_dependent/UploadedFile.t
new file mode 100755
index 0000000..dd01e1b
--- /dev/null
+++ b/t/db_dependent/UploadedFile.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+#
+# This Koha test module is a stub!  
+# Add more tests here!!!
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+BEGIN {
+        use_ok('C4::UploadedFile');
+}
+
diff --git a/t/db_dependent/VirtualShelves_Page.t b/t/db_dependent/VirtualShelves_Page.t
new file mode 100755
index 0000000..236d147
--- /dev/null
+++ b/t/db_dependent/VirtualShelves_Page.t
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+#
+# This Koha test module is a stub!  
+# Add more tests here!!!
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+BEGIN {
+        use_ok('C4::VirtualShelves::Page');
+}
+
-- 
1.7.1



More information about the Koha-patches mailing list