From c3488c076d6e12f61528e4267b01d703562042c6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 10 Dec 2020 16:55:55 +0100 Subject: [PATCH] Bug 27190: Test::Mojo - Always warn the error string on error --- t/db_dependent/api/v1/holds.t | 7 ++++--- t/lib/Mojo.pm | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 t/lib/Mojo.pm diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t index cb683fd819..b8090ca592 100755 --- a/t/db_dependent/api/v1/holds.t +++ b/t/db_dependent/api/v1/holds.t @@ -43,8 +43,8 @@ my $builder = t::lib::TestBuilder->new(); $schema->storage->txn_begin; t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); - -my $t = Test::Mojo->new('Koha::REST::V1'); +use t::lib::Mojo; +my $t = t::lib::Mojo->new('Koha::REST::V1'); my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; @@ -832,7 +832,8 @@ subtest 'PUT /holds/{hold_id}/pickup_location tests' => sub { $t->put_ok( "//$userid:$password@/api/v1/holds/" . $hold->id - . "/pickup_location" => json => $library_2->branchcode )->status_is(200)->json_is($library_2->branchcode); + . "/pickup_location" => json => $library_2->branchcode ) + ->status_is(200)->json_is( $library_2->branchcode ); is( $hold->discard_changes->branchcode->branchcode, $library_2->branchcode, 'pickup library adjusted correctly' ); diff --git a/t/lib/Mojo.pm b/t/lib/Mojo.pm new file mode 100644 index 0000000000..f53d09ce9e --- /dev/null +++ b/t/lib/Mojo.pm @@ -0,0 +1,12 @@ +package t::lib::Mojo; + +use base qw(Test::Mojo); + +sub test { + my ($self, @params) = @_; + my $ok = $self->SUPER::test(@params); + warn "DIAG: " . $self->tx->res->to_string unless $ok->success; + return $ok +} + +1; -- 2.20.1