diff options
Diffstat (limited to '')
-rw-r--r-- | t/00_compile.t | 4 | ||||
-rw-r--r-- | t/01_basic.t | 3 | ||||
-rw-r--r-- | t/10_mx_net_api_test.t | 43 | ||||
-rw-r--r-- | t/lib/TestAPI.pm | 19 | ||||
-rw-r--r-- | t/lib/TestApp.pm | 11 | ||||
-rw-r--r-- | t/lib/TestApp/Controller/Root.pm | 16 |
6 files changed, 94 insertions, 2 deletions
diff --git a/t/00_compile.t b/t/00_compile.t index 86438a0..10b03a4 100644 --- a/t/00_compile.t +++ b/t/00_compile.t @@ -1,4 +1,4 @@ use strict; -use Test::More tests => 1; +use Test::More tests => 2; -BEGIN { use_ok 'MooseX::Net::API' } +BEGIN { use_ok 'MooseX::Net::API'; use_ok 'MooseX::Net::API::Test' } diff --git a/t/01_basic.t b/t/01_basic.t index 9c108d2..471f3dd 100644 --- a/t/01_basic.t +++ b/t/01_basic.t @@ -29,4 +29,7 @@ throws_ok { } qr/foo is not declared as a param/, "... check declared params"; +ok my @methods = $obj->meta->local_api_methods(), '... get api methods'; +is scalar @methods, 3, '... got 3 methods in our API'; + done_testing; diff --git a/t/10_mx_net_api_test.t b/t/10_mx_net_api_test.t new file mode 100644 index 0000000..96bf2be --- /dev/null +++ b/t/10_mx_net_api_test.t @@ -0,0 +1,43 @@ +use strict; +use warnings; +use Test::More; + +BEGIN { + plan skip_all => 'requires Catalyst::Action::REST' + unless eval { require Catalyst::Action::REST }; +} + +{ + + package catalysttestapi; + use Moose; + use MooseX::Net::API::Test; + + test_api_declare 'TestAPI' => ( + catalyst => 1, + catalyst_app_name => 'TestApp' + ); + + test_api_method foo => ( + tests => { + simple => [ + { + # pouvoir surcharger + test => 'is_deeply', + expected => { status => 1 } + }, + 'ok', + ] + } + ); +} + +#content_like => [ { expected => qr/status: 1/ }, ], +#action_ok => [], +#action_redirect => [], +#action_notfound => [], +#contenttype_is => [], + +catalysttestapi->run(); + +done_testing; diff --git a/t/lib/TestAPI.pm b/t/lib/TestAPI.pm new file mode 100644 index 0000000..1f58351 --- /dev/null +++ b/t/lib/TestAPI.pm @@ -0,0 +1,19 @@ +package TestAPI; +use Moose; +use MooseX::Net::API; + +net_api_declare fake_api => ( + base_url => 'http://localhost/root', + format => 'json', + format_mode => 'content-type', + require_authentication => 0, +); + +net_api_method foo => ( + description => 'this does foo', + method => 'GET', + path => '/foo/', +); + +1; + diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm new file mode 100644 index 0000000..69ec93d --- /dev/null +++ b/t/lib/TestApp.pm @@ -0,0 +1,11 @@ +package TestApp; +use strict; +use warnings; + +use Catalyst; + +__PACKAGE__->config( name => 'TestApp', ); + +__PACKAGE__->setup; + +1; diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm new file mode 100644 index 0000000..7ea3f25 --- /dev/null +++ b/t/lib/TestApp/Controller/Root.pm @@ -0,0 +1,16 @@ +package TestApp::Controller::Root; + +use strict; +use warnings; +use base qw/Catalyst::Controller::REST/; + +sub foo : Local : ActionClass('REST') { + my ( $self, $c ) = @_; +} + +sub foo_GET { + my ( $self, $c ) = @_; + $self->status_ok( $c, entity => { status => 1 } ); +} + +1; |