Skip to content

Commit

Permalink
Merge branch 'fd-4267-car-parks-question' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Dec 6, 2024
2 parents a89bb0c + dc38132 commit 709a92f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions perllib/Integrations/Confirm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ sub perform_request_graphql {

my $content = decode_json($response->content);

if ($content->{errors}) {
$self->logger->warn("Got errors in response to GraphQL query $encoded_body: $response->{content} ");
if ($content->{errors} && @{$content->{errors}}) {
$self->logger->warn("Got errors in response to GraphQL query $encoded_body: " . $response->content);
}

return $content;
Expand Down
4 changes: 4 additions & 0 deletions perllib/Open311/Endpoint/Integration/UK/Brent/Echo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ around process_service_request_args => sub {
my ($orig, $class, $args) = @_;
my $request = $class->$orig($args);

if ($args->{attributes}{CarParkIssueType}) {
$args->{attributes}{description} .= " | " . $args->{attributes}{CarParkIssueType});
}

# Missed collection
if ($request->{event_type} == 2891) {
my $service_id = $args->{attributes}{service_id};
Expand Down
43 changes: 43 additions & 0 deletions t/integrations/confirm.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package Integrations::Confirm::Dummy;
use Path::Tiny;
use Moo;
extends 'Integrations::Confirm';
sub _build_config_file { path(__FILE__)->sibling("confirm.yml")->stringify }

package main;

use strict;
use warnings;

use Test::More;
use Test::MockModule;
use Test::Output;
use HTTP::Response;
use JSON::MaybeXS;

BEGIN { $ENV{TEST_MODE} = 1; }

my $lwp = Test::MockModule->new('LWP::UserAgent');

$lwp->mock(request => sub {
return HTTP::Response->new(200, 'OK', [], encode_json({
data => {},
errors => [
{
message => "Uh-oh spaghettio!",
}
]
})
);
});

my $integration = Integrations::Confirm::Dummy->new;

subtest "GraphQL errors are logged " => sub {
local $ENV{TEST_LOGGER} = 'warn';
stderr_like {
$integration->perform_request_graphql(type => 'job_types');
} qr/.*Uh-oh spaghettio!.*/, 'Got expected warning log for errors.';
};

done_testing;
2 changes: 2 additions & 0 deletions t/integrations/confirm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
graphql_url: "http://example.org/graphql"
graphql_key: "key"

0 comments on commit 709a92f

Please sign in to comment.