Add batch update test of mixed items
authorJason Stephenson <jason@sigio.com>
Sat, 8 Jan 2022 20:09:16 +0000 (15:09 -0500)
committerJason Stephenson <jason@sigio.com>
Sat, 8 Jan 2022 20:09:16 +0000 (15:09 -0500)
Open-ILS/src/perlmods/live_t/lp1883171-copy-inventory.t

index 3a01714..21be3f1 100755 (executable)
@@ -354,6 +354,43 @@ if ($editor->update_asset_copy($fcopy)) {
     BAIL_OUT('Set copy floating failed');
 }
 
+# Test a batch update where some succeed and some fail.
+$resp = $editor->search_asset_copy([
+    {circ_lib => BR2_ID, status => 0, floating => undef},
+    {limit => 5, idlist => 1}
+]);
+ok(
+    $resp && scalar(@{$resp}) == 5,
+    'Got 5 copies from branch 2'
+);
+undef($copies);
+push(@{$copies}, @{$resp});
+$resp = $editor->search_asset_copy([
+    {circl_lib => BR1_ID, status => 0},
+    {limit => 5, idlist => 1}
+]);
+ok(
+    $resp && scalar(@{$resp}) == 5,
+    'Got 5 copies from branch 1'
+);
+push(@{$copies}, @{$resp});
+$resp = $U->simplereq(
+    'open-ils.circ',
+    'open-ils.circ.circulation.update_copy_inventory',
+    $authtoken,
+    {copy_list=>$copies}
+);
+is(
+    $resp->[0],
+    5,
+    'Updated inventory on 5 copies'
+);
+is(
+    $resp->[1],
+    5,
+    'Did not update inventory on 5 copies'
+);
+
 # We could run 36 or more tests depending on what we find in the
 # database, so we don't specify a number of tests.
 done_testing();