diff options
author | Marius Halden <marius.h@lden.org> | 2021-10-07 13:32:40 +0200 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2021-10-07 13:32:40 +0200 |
commit | 09dacfc6b8bf62addeee16c20b1d90c2a256da96 (patch) | |
tree | 7caa2bf9e92227ab74448f9b746dd28bbcb81b2a /t/Mock/Bing.pm | |
parent | 585e57484f9c6332668bf1ac0a6a3b39dbe32223 (diff) | |
parent | cea89fb87a96943708a1db0f646492fbfaaf000f (diff) |
Merge tag 'v3.1' into fiksgatami-devfiksgatami-dev
Diffstat (limited to 't/Mock/Bing.pm')
-rw-r--r-- | t/Mock/Bing.pm | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/t/Mock/Bing.pm b/t/Mock/Bing.pm index 3dfb8fbe0..cc4dab845 100644 --- a/t/Mock/Bing.pm +++ b/t/Mock/Bing.pm @@ -14,6 +14,53 @@ has json => ( sub dispatch_request { my $self = shift; + sub (GET + /REST/v1/Locations + ?*) { + my ($self, $query) = @_; + my $results = [ { + point => { coordinates => [ 51, -1 ] }, + name => 'Constitution Hill, London, SW1A', + confidence => 'High', + address => { + addressLine => 'Constitution Hill', + locality => 'London', + countryRegion => 'United Kingdom', + } + } ]; + if ($query->{q} =~ /two results/) { + push @$results, { + point => { coordinates => [ 51, -1 ] }, + name => 'Constitution Hill again, United Kingdom', + confidence => 'High', + address => { + addressLine => 'Constitution Hill again', + locality => 'London', + countryRegion => 'United Kingdom', + } + }; + } + if ($query->{q} =~ /low/) { + push @$results, { + point => { coordinates => [ 52, -2 ] }, + name => 'Constitution Hill elsewhere, United Kingdom', + confidence => 'Low', + address => { + addressLine => 'Constitution Hill elsewhere', + locality => 'London', + countryRegion => 'United Kingdom', + } + }; + } + if ($query->{q} =~ /onlylow/) { + @$results = map { $_->{confidence} = 'Low'; $_ } @$results; + } + my $data = { + statusCode => 200, + resourceSets => [ { resources => $results } ], + }; + my $json = $self->json->encode($data); + return [ 200, [ 'Content-Type' => 'application/json' ], [ $json ] ]; + }, + sub (GET + /REST/v1/Locations/* + ?*) { my ($self, $location, $query) = @_; my $data = { |