Started on user day entry
This commit is contained in:
parent
b03b7ccc5f
commit
1598909958
6 changed files with 142 additions and 1 deletions
|
@ -1,8 +1,10 @@
|
|||
package Test::Pear::LocalLoop;
|
||||
use Mojo::Base -base;
|
||||
|
||||
use Test::More;
|
||||
use File::Temp;
|
||||
use Test::Mojo;
|
||||
use DateTime::Format::Strptime;
|
||||
|
||||
has config => sub {
|
||||
my $file = File::Temp->new;
|
||||
|
@ -38,4 +40,40 @@ has framework => sub {
|
|||
return $t;
|
||||
};
|
||||
|
||||
sub dump_error {
|
||||
return sub {
|
||||
my $self = shift;
|
||||
if ( my $error = $self->tx->res->dom->at('pre[id="error"]') ) {
|
||||
diag $error->text;
|
||||
} else {
|
||||
diag $self->tx->res->to_string;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
sub register_customer {
|
||||
my $self = shift;
|
||||
my $args = shift;
|
||||
|
||||
my $json = {
|
||||
usertype => 'customer',
|
||||
%$args,
|
||||
};
|
||||
|
||||
$self->framework->post_ok('/api/register' => json => $json)
|
||||
->status_is(200)->or($self->dump_error)
|
||||
->json_is('/success', Mojo::JSON->true)->or($self->dump_error);
|
||||
}
|
||||
|
||||
sub login {
|
||||
my $self = shift;
|
||||
my $args = shift;
|
||||
|
||||
$self->framework->post_ok('/api/login' => json => $args)
|
||||
->status_is(200)->or($self->dump_error)
|
||||
->json_is('/success', Mojo::JSON->true)->or($self->dump_error);
|
||||
|
||||
return $self->framework->tx->res->json->{session_key};
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Reference in a new issue