@@ -, +, @@ between tests $ kshell k$ prove t/db_dependent/api/v1/patrons.t # Failed test 'Returned patron from update matches expected' # at t/db_dependent/api/v1/patrons.t line 513. # Structures begin differing at: # $got->{updated_on} = '2021-06-25T14:26:20+00:00' # $expected->{updated_on} = '2021-06-25T14:26:19+00:00' # Looks like you failed 1 test of 42. --- t/db_dependent/api/v1/patrons.t | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) --- a/t/db_dependent/api/v1/patrons.t +++ a/t/db_dependent/api/v1/patrons.t @@ -409,6 +409,8 @@ subtest 'update() tests' => sub { delete $newpatron->{patron_id}; delete $newpatron->{restricted}; delete $newpatron->{anonymized}; + # delete field set by a trigger because it is fragile for comparisons + delete $newpatron->{updated_on}; $t->put_ok("//$userid:$password@/api/v1/patrons/-1" => json => $newpatron) ->status_is(404) @@ -475,13 +477,23 @@ subtest 'update() tests' => sub { $newpatron->{ surname } = "user" . $patron_1->id.$patron_2->id; my $result = $t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) - ->status_is(200, 'Patron updated successfully'); - - # Put back the RO attributes - $newpatron->{patron_id} = $unauthorized_patron->to_api->{patron_id}; - $newpatron->{restricted} = $unauthorized_patron->to_api->{restricted}; - $newpatron->{anonymized} = $unauthorized_patron->to_api->{anonymized}; - is_deeply($result->tx->res->json, $newpatron, 'Returned patron from update matches expected'); + ->status_is(200, 'Patron updated successfully')->tx->res->json; + + # Test the updated attributes are returned correctly + my $matches = 0; + my @attributes = keys %{$newpatron}; + foreach my $attribute (@attributes) { + if ( exists $result->{$attribute} + and $result->{$attribute} eq $newpatron->{$attribute} ) { + $matches++; + } + else { + warn $result->{$attribute} . " vs " . $newpatron->{$attribute} . " ($attribute)"; + } + + } + + is( $matches, scalar @attributes, 'Returned patron from update matches expected' ); is(Koha::Patrons->find( $patron_2->id )->cardnumber, $newpatron->{ cardnumber }, 'Patron is really updated!'); --