Skip to content

Commit

Permalink
More test work
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Waters committed Sep 22, 2012
1 parent d04b685 commit 32166d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
*.tar.gz
.workonrc
24 changes: 19 additions & 5 deletions t/003_handler.t
Expand Up @@ -6,12 +6,12 @@ use Dancer qw(config);
use Dancer::Test;
use Dancer::Plugin::Tapir;

config->{plugins}{Tapir} = {
thrift_idl => $FindBin::Bin . '/thrift/example.thrift',
handler_class => 'MyWebApp::Handler',
};
# We're going to redefine methods; let's ignore warnings about it
$Tapir::Server::Handler::Signatures::ALLOW_REDEFINE = 1;

# Avoid errors with "require MyWebApp::Handler"
$INC{'MyWebApp/Handler.pm'} = undef;

{
package MyWebApp::Handler;

Expand Down Expand Up @@ -39,7 +39,9 @@ $INC{'MyWebApp/Handler.pm'} = undef;
}
}

setup_thrift_handler;
setup_thrift_handler
thrift_idl => $FindBin::Bin . '/thrift/example.thrift',
handler_class => 'MyWebApp::Handler';

response_status_is [ GET => '/' ], 404, "No root route";

Expand All @@ -49,4 +51,16 @@ response_status_is [ POST => '/accounts?username=johndoe&password=abc123' ], 200

response_status_is [ GET => '/account/johndoe' ], 500, "GET /account/:username threw error due to invalid set_result() call";

{
package MyWebApp::Handler;
method getAccount ($username) {
$call->set_result({
id => 42,
allocation => 1000,
});
}
}

response_status_is [ GET => '/account/johndoe' ], 200, "GET /account/:username with valid set_result()";

done_testing;

0 comments on commit 32166d3

Please sign in to comment.