Bug 29806: Regression tests
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 6 Jan 2022 12:27:28 +0000 (09:27 -0300)
committerFridolin Somers <fridolin.somers@biblibre.com>
Wed, 19 Jan 2022 22:13:49 +0000 (12:13 -1000)
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
t/db_dependent/api/v1/holds.t

index 006c616..abf23d4 100755 (executable)
@@ -1066,7 +1066,7 @@ subtest 'edit() tests' => sub {
 
 subtest 'add() tests' => sub {
 
-    plan tests => 10;
+    plan tests => 16;
 
     $schema->storage->txn_begin;
 
@@ -1185,6 +1185,24 @@ subtest 'add() tests' => sub {
     $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $item_hold_data )
       ->status_is(201);
 
+    # empty cases
+    $mock_biblio->mock( 'pickup_locations', sub {
+        return Koha::Libraries->new->empty;
+    });
+
+    $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $biblio_hold_data )
+      ->status_is(400)
+      ->json_is({ error => 'The supplied pickup location is not valid' });
+
+    # empty cases
+    $mock_item->mock( 'pickup_locations', sub {
+        return Koha::Libraries->new->empty;
+    });
+
+    $t->post_ok( "//$userid:$password@/api/v1/holds" => json => $item_hold_data )
+      ->status_is(400)
+      ->json_is({ error => 'The supplied pickup location is not valid' });
+
     $schema->storage->txn_rollback;
 };