Bug 9819: Make the tests pass
[srvgit] / t / NorwegianPatronDB.t
index acbe045..1f0808c 100644 (file)
@@ -23,36 +23,41 @@ use Data::Dumper;
 
 # Check that all the modules we need are installed, or bail out
 BEGIN {
+    my $missing_lib;
     eval {
         require Test::DBIx::Class;
         1;
     } or do {
-        plan skip_all => "Test::DBIx::Class is not available";
+        $missing_lib = "Test::DBIx::Class";
     };
-}
-BEGIN {
+
     eval {
         require SOAP::Lite;
         1;
     } or do {
-        plan skip_all => "SOAP::Lite is not available";
+        $missing_lib = "SOAP::Lite";
     };
-}
-BEGIN {
+
     eval {
         require Crypt::GCrypt;
         1;
     } or do {
-        plan skip_all => "Crypt::GCrypt is not available";
+        $missing_lib = "Crypt::GCrypt";
     };
-}
-BEGIN {
+
     eval {
         require Convert::BaseN;
         1;
     } or do {
-        plan skip_all => "Convert::BaseN is not available";
+        $missing_lib = "Convert::BaseN";
     };
+
+    if ( $missing_lib ) {
+        plan skip_all => $missing_lib . " is not available.";
+    } else {
+        # Everything good
+        plan tests => 73;
+    }
 }
 
 use Test::DBIx::Class {
@@ -113,10 +118,16 @@ Relevant sysprefs:
 
 =cut
 
+BEGIN {
+    t::lib::Mocks::mock_config('nlkey',        'key');
+    t::lib::Mocks::mock_config('nlvendoruser', 'user');
+    t::lib::Mocks::mock_config('nlvendorpass', 'pass');
+}
 t::lib::Mocks::mock_preference('NorwegianPatronDBEnable',   0);
 t::lib::Mocks::mock_preference('NorwegianPatronDBEndpoint', '');
 t::lib::Mocks::mock_preference('NorwegianPatronDBUsername', '');
 t::lib::Mocks::mock_preference('NorwegianPatronDBPassword', '');
+
 ok( my $result = NLCheckSysprefs(), 'call NLCheckSysprefs() ok' );
 is( $result->{ 'error' },     1, 'error detected' );
 is( $result->{ 'nlenabled' }, 0, 'NL is not enabled' );
@@ -298,8 +309,6 @@ is( $res->{'melding'}, 'ingen treff', 'got "ingen treff"' );
 is( $res->{'antall_poster_returnert'}, 0, 'got 0 records' );
 is( $res->{'antall_treff'}, 0, 'got 0 records' );
 
-done_testing();
-
 =head1 SAMPLE SOAP XML RESPONSES
 
 These responses can be gathered by setting "outputxml()" to true on the SOAP