Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Wrap data prep tests in a subtest for cleaner TAP
The tests only happen once, but it can be confusing to see them when varying
which test are run.  Since it's all related, stick it under one group.
Then it only counts as 1 test in the end.
  • Loading branch information
rwstauner committed Aug 9, 2014
1 parent e40dd76 commit 1db6059
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions lib/MetaCPAN/Server/Test.pm
Expand Up @@ -6,7 +6,7 @@ use warnings;
use HTTP::Request::Common qw(POST GET DELETE);
use JSON::XS;
use Plack::Test;
use Test::More;
use Test::More 0.96;
use Try::Tiny;

use base 'Exporter';
Expand All @@ -28,23 +28,32 @@ BEGIN { $ENV{METACPAN_SERVER_CONFIG_LOCAL_SUFFIX} = 'testing'; }
}

my $app = require MetaCPAN::Server;
ok(
my $user = MetaCPAN::Server->model('User::Account')->put(
{ access_token => [ { client => 'testing', token => 'testing' } ] }
),
'prepare user'
);
ok( $user->add_identity( { name => 'pause', key => 'MO' } ),
'add pause identity' );
ok( $user->put( { refresh => 1 } ), 'put user' );

ok(
MetaCPAN::Server->model('User::Account')->put(
{ access_token => [ { client => 'testing', token => 'bot' } ] },
{ refresh => 1 }
),
'put bot user'
);

subtest 'prepare server test data' => sub {

ok(
my $user = MetaCPAN::Server->model('User::Account')->put(
{
access_token =>
[ { client => 'testing', token => 'testing' } ]
}
),
'prepare user'
);
ok( $user->add_identity( { name => 'pause', key => 'MO' } ),
'add pause identity' );
ok( $user->put( { refresh => 1 } ), 'put user' );

ok(
MetaCPAN::Server->model('User::Account')->put(
{ access_token => [ { client => 'testing', token => 'bot' } ] },
{ refresh => 1 }
),
'put bot user'
);

};

sub app {$app}

require MetaCPAN::Model;
Expand Down

0 comments on commit 1db6059

Please sign in to comment.