diff --git a/cpanfile b/cpanfile index 1916f82..5ef4b1f 100644 --- a/cpanfile +++ b/cpanfile @@ -6,7 +6,6 @@ requires 'Mojo::JSON'; requires 'Email::Valid'; requires 'Geo::UK::Postcode::Regex' => '0.017'; requires 'Authen::Passphrase::BlowfishCrypt'; -requires 'Time::Fake'; requires 'Scalar::Util'; requires 'DBIx::Class'; requires 'DBIx::Class::PassphraseColumn'; @@ -25,6 +24,11 @@ requires 'GIS::Distance'; requires 'Text::CSV'; requires 'Try::Tiny'; +on 'test' => sub { + requires 'Test::More'; + requires 'Test::MockTime'; +}; + feature 'schema-graph', 'Draw diagrams of Schema' => sub { requires 'GraphViz'; requires 'SQL::Translator'; @@ -38,4 +42,3 @@ feature 'postgres', 'PostgreSQL Support' => sub { feature 'codepoint-open', 'Code Point Open manipulation' => sub { requires 'Geo::UK::Postcode::CodePointOpen'; }; - diff --git a/t/api/stats.t b/t/api/stats.t index 620f5d3..4fe849b 100644 --- a/t/api/stats.t +++ b/t/api/stats.t @@ -1,5 +1,9 @@ use Mojo::Base -strict; +BEGIN { + use Test::MockTime qw/ set_absolute_time /; +} + use FindBin qw/ $Bin /; use Test::More; @@ -15,6 +19,8 @@ $framework->install_fixtures('users'); my $t = $framework->framework; my $schema = $t->app->schema; +set_absolute_time('2017-01-01T00:00:00Z'); + my $start = DateTime->today->subtract( hours => 12 ); # create 40 days worth of data @@ -45,7 +51,7 @@ $t->post_ok('/api/stats/customer' => json => { }) ->status_is(200)->or($framework->dump_error) ->json_is('/weeks', { - purchases => [ 8, 21, 19, 22, 20, 20, 8 ], + purchases => [ 2, 21, 20, 21, 19, 22, 13 ], }) ->json_is('/sectors', { sectors => ['A'],