-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
237 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
*.bak | ||
.paia_session | ||
paia-session.json | ||
paia.json | ||
.build | ||
App-PAIA-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
requires 'App::Cmd', '0.322'; # CLI framework | ||
requires 'JSON::PP', '2.27103'; # core module since Perl v5.13.9 | ||
requires 'HTTP::Tiny', '0.024'; # core module since Perl v5.17.7 | ||
requires 'IO::Socket::SSL', '1.56'; # for HTTPS | ||
requires 'Net::SSLeay', '1.49'; # for HTTPS | ||
requires 'App::Cmd', '0.322'; # CLI framework | ||
requires 'JSON::PP', '2.27103'; # core module since Perl v5.13.9 | ||
requires 'HTTP::Tiny', '0.024'; # core module since Perl v5.17.7 | ||
requires 'IO::Socket::SSL', '1.56'; # for HTTPS | ||
requires 'Net::SSLeay', '1.49'; # for HTTPS | ||
# requires 'Mozilla::CA'; # see https://metacpan.org/module/HTTP::Tiny#SSL-SUPPORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#ABSTRACT: Facilitate PAIA client unit tests | ||
package App::PAIA::Tester; | ||
use strict; | ||
use v5.10; | ||
#VERSION | ||
|
||
use parent 'Exporter'; | ||
our @cmd = qw(stdout stderr output error exit_code); | ||
our @EXPORT = (qw(new_paia_test done_paia_test paia stdout_json debug), @cmd); | ||
|
||
use Test::More; | ||
use App::Cmd::Tester; | ||
use JSON::PP; | ||
use File::Temp qw(tempdir); | ||
use Cwd; | ||
use App::PAIA; | ||
|
||
our $CWD = getcwd(); | ||
our $RESULT; | ||
|
||
eval "sub $_ { \$RESULT->$_ }" for @cmd; ## no critic | ||
|
||
sub stdout_json { | ||
decode_json($RESULT->stdout); | ||
} | ||
|
||
sub new_paia_test { | ||
chdir tempdir(); | ||
} | ||
|
||
sub paia(@) { ## no critic | ||
$RESULT = test_app('App::PAIA' => [@_]); | ||
} | ||
|
||
sub done_paia_test { | ||
chdir $CWD; | ||
done_testing; | ||
} | ||
|
||
sub debug { | ||
say "# $_" for split "\n", join "\n", ( | ||
"stdout: ".$RESULT->stdout, | ||
"stderr: ".$RESULT->stderr, | ||
"error: ".$RESULT->error // 'undef', | ||
"exit_code: ".$RESULT->exit_code | ||
); | ||
} | ||
|
||
=head1 SYNOPSIS | ||
use Test::More; | ||
use App::PAIA::Tester; | ||
new_paia_test; | ||
paia qw(config base http://example.org/); | ||
is error, undef; | ||
paia qw(config); | ||
is_deeply stdout_json, { | ||
base => 'http://example.org/' | ||
}; | ||
paia qw(login -u alice -p 1234); | ||
is stderr, ''; | ||
is exit_code, 0; | ||
my $token = stdout_json->{access_token}; | ||
ok $token; | ||
done_paia_test; | ||
=head1 DESCRIPTION | ||
The module implements a simple a singleton wrapper around L<App::Cmd::Tester> | ||
to facilitate writing unit tests for the paia client L<App::PAIA>. | ||
=cut | ||
|
||
1; |
Oops, something went wrong.