Add test cases for a multitude of query and change cache definition

The code coverage will be complete when there are test cases for a multitude
of queries. Also, as the goodie always return the same set of results for the
trigger query - cache can be set.

* cache set

* added test cases
master
NaveenKarippai 2016-06-09 17:34:22 +00:00
parent c1ce7ecaf2
commit 34ff2f032d
2 changed files with 47 additions and 31 deletions

View File

@ -11,7 +11,7 @@ my $triggers = LoadFile(share('triggers.yml'));
triggers any => @$triggers;
zci answer_type => 'helpline';
zci is_cached => 0;
zci is_cached => 1;
my $helplines = LoadFile(share('helplines.yml'));
my %suicide_phrases = map { $_ => 1 } @$triggers;

View File

@ -9,34 +9,7 @@ use DDG::Test::Location;
use DDG::Request;
zci answer_type => 'helpline';
zci is_cached => 0;
my @queries = (
'suicide',
'suicide hotline',
'kill myself',
'suicidal thoughts',
'end my life',
'suicidal thoughts',
'suicidal',
'suicidal ideation',
'i want to kill myself',
'commit suicide',
'suicide pills',
'suicide pill',
'suicide prevention',
'kill myself',
);
my @locations = (
'au',
'us',
);
my @ok_queries = (
'suicide girls',
'suicide silence',
);
zci is_cached => 1;
sub build_structured_answer{
my ($result, $num, $country) = @_;
@ -72,6 +45,7 @@ ddg_goodie_test(
[qw(
DDG::Goodie::HelpLine
)],
DDG::Request->new(
query_raw => 'suicide',
location => test_location('us'),
@ -79,21 +53,63 @@ ddg_goodie_test(
build_test(@test_us),
DDG::Request->new(
query_raw => 'suicide',
query_raw => 'kill myself',
location => test_location('de'),
),
build_test(@test_de),
DDG::Request->new(
query_raw => 'suicide',
query_raw => 'suicide hotline',
location => test_location('au'),
),
build_test(@test_au),
DDG::Request->new(
query_raw => 'suicide prevention',
location => test_location('us'),
),
build_test(@test_us),
DDG::Request->new(
query_raw => 'end my life',
location => test_location('au'),
),
build_test(@test_au),
DDG::Request->new(
query_raw => 'i want to kill myself',
location => test_location('us'),
),
build_test(@test_us),
DDG::Request->new(
query_raw => 'commit suicide',
location => test_location('au'),
),
build_test(@test_au),
DDG::Request->new(
query_raw => 'suicide pills',
location => test_location('de'),
),
build_test(@test_de),
DDG::Request->new(
query_raw => 'suicidal ideation',
location => test_location('de'),
),
build_test(@test_de),
DDG::Request->new(
query_raw => 'suicide silence',
location => test_location('us'),
),
undef,
DDG::Request->new(
query_raw => 'suicide girls',
location => test_location('au'),
),
undef
);