diff options
Diffstat (limited to 't')
-rw-r--r-- | t/00-check-config.t | 51 | ||||
-rw-r--r-- | t/Mock/Nominatim.pm | 5 | ||||
-rw-r--r-- | t/cobrand/fixamingata.t | 10 |
3 files changed, 10 insertions, 56 deletions
diff --git a/t/00-check-config.t b/t/00-check-config.t deleted file mode 100644 index 00e782e74..000000000 --- a/t/00-check-config.t +++ /dev/null @@ -1,51 +0,0 @@ -use strict; -use warnings; - -use Test::More; -use YAML; - -use FixMyStreet; - -# check that all the fields listed in general.yml-example are also present in -# general.yml - helps prevent later test failures due to un-noticed additions to the -# config file. - -# This code will bail_out to prevent the test suite proceeding to save time if -# issues are found. - -# load the config file and store the contents in a readonly hash - -my $example_config = YAML::LoadFile( FixMyStreet->path_to("conf/general.yml-example") ); -my $CONF_FILE = $ENV{FMS_OVERRIDE_CONFIG} || 'general'; -my $local_config = YAML::LoadFile( FixMyStreet->path_to("conf/${CONF_FILE}.yml") ); - -# find all keys missing from each config -my @missing_from_example = find_missing( $example_config, $local_config ); -my @missing_from_local = find_missing( $local_config, $example_config ); - -if ( @missing_from_example || @missing_from_local ) { - - fail "Missing from 'general.yml': $_" for @missing_from_local; - fail "Missing from 'general.yml-example': $_" for @missing_from_example; - - # bail out to prevent other tests failing due to config issues - BAIL_OUT( "Config has changed" - . " - update your 'general.yml' and add/remove the keys listed above" ); -} -else { - pass "configs contain the same keys"; -} - -done_testing(); - -sub find_missing { - my $reference = shift; - my $config = shift; - my @missing = (); - - foreach my $key ( sort keys %$config ) { - push @missing, $key unless exists $reference->{$key}; - } - - return @missing; -} diff --git a/t/Mock/Nominatim.pm b/t/Mock/Nominatim.pm index 5c8c549d1..5edbc9b30 100644 --- a/t/Mock/Nominatim.pm +++ b/t/Mock/Nominatim.pm @@ -13,6 +13,11 @@ has json => ( sub dispatch_request { my $self = shift; + sub (GET + /reverse + ?*) { + my ($self) = @_; + return [ 200, [ 'Content-Type' => 'text/xml' ], [ '<result></result>' ] ]; + }, + sub (GET + /search + ?q=) { my ($self, $q) = @_; my $response = $self->query($q); diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index 1e6bd7e65..06b5830e3 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -1,13 +1,10 @@ -use Test::MockModule; - use mySociety::Locale; use FixMyStreet::TestMech; my $mech = FixMyStreet::TestMech->new; -# Closest road reverse geocode mock -my $resolver = Test::MockModule->new('LWP::Simple'); -$resolver->mock('get', sub($) { "<result></result>" }); +use t::Mock::Nominatim; +LWP::Protocol::PSGI->register(t::Mock::Nominatim->to_psgi_app, host => 'nominatim.openstreetmap.org'); # Front page test @@ -103,6 +100,9 @@ subtest "Test ajax decimal points" => sub { $mech->get_ok('/ajax/lookup_location?term=12345'); # We want an actual decimal point in a JSON response... $mech->content_contains('51.5'); + + $mech->get_ok('/ajax/lookup_location?term=high+street'); + $mech->content_contains('Edinburgh'); }; }; |