Fixed stats test

This commit is contained in:
Finn 2017-12-18 14:05:51 +00:00
parent 3914ec44a8
commit f1c1748b34
2 changed files with 12 additions and 3 deletions

View file

@ -6,7 +6,6 @@ requires 'Mojo::JSON';
requires 'Email::Valid'; requires 'Email::Valid';
requires 'Geo::UK::Postcode::Regex' => '0.017'; requires 'Geo::UK::Postcode::Regex' => '0.017';
requires 'Authen::Passphrase::BlowfishCrypt'; requires 'Authen::Passphrase::BlowfishCrypt';
requires 'Time::Fake';
requires 'Scalar::Util'; requires 'Scalar::Util';
requires 'DBIx::Class'; requires 'DBIx::Class';
requires 'DBIx::Class::PassphraseColumn'; requires 'DBIx::Class::PassphraseColumn';
@ -25,6 +24,11 @@ requires 'GIS::Distance';
requires 'Text::CSV'; requires 'Text::CSV';
requires 'Try::Tiny'; requires 'Try::Tiny';
on 'test' => sub {
requires 'Test::More';
requires 'Test::MockTime';
};
feature 'schema-graph', 'Draw diagrams of Schema' => sub { feature 'schema-graph', 'Draw diagrams of Schema' => sub {
requires 'GraphViz'; requires 'GraphViz';
requires 'SQL::Translator'; requires 'SQL::Translator';
@ -38,4 +42,3 @@ feature 'postgres', 'PostgreSQL Support' => sub {
feature 'codepoint-open', 'Code Point Open manipulation' => sub { feature 'codepoint-open', 'Code Point Open manipulation' => sub {
requires 'Geo::UK::Postcode::CodePointOpen'; requires 'Geo::UK::Postcode::CodePointOpen';
}; };

View file

@ -1,5 +1,9 @@
use Mojo::Base -strict; use Mojo::Base -strict;
BEGIN {
use Test::MockTime qw/ set_absolute_time /;
}
use FindBin qw/ $Bin /; use FindBin qw/ $Bin /;
use Test::More; use Test::More;
@ -15,6 +19,8 @@ $framework->install_fixtures('users');
my $t = $framework->framework; my $t = $framework->framework;
my $schema = $t->app->schema; my $schema = $t->app->schema;
set_absolute_time('2017-01-01T00:00:00Z');
my $start = DateTime->today->subtract( hours => 12 ); my $start = DateTime->today->subtract( hours => 12 );
# create 40 days worth of data # create 40 days worth of data
@ -45,7 +51,7 @@ $t->post_ok('/api/stats/customer' => json => {
}) })
->status_is(200)->or($framework->dump_error) ->status_is(200)->or($framework->dump_error)
->json_is('/weeks', { ->json_is('/weeks', {
purchases => [ 8, 21, 19, 22, 20, 20, 8 ], purchases => [ 2, 21, 20, 21, 19, 22, 13 ],
}) })
->json_is('/sectors', { ->json_is('/sectors', {
sectors => ['A'], sectors => ['A'],