summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-03 09:58:35 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-03 09:58:35 +0200
commit279995a5e1ef8142889c3cfa2f07a4082b0a52ab (patch)
treee5a138626e5019386ea179ff0824dfc43165b309
parentupdate POD (diff)
downloadmoosex-net-api-279995a5e1ef8142889c3cfa2f07a4082b0a52ab.tar.gz
basic tests for serialization
-rw-r--r--t/03_serialization.t10
-rw-r--r--t/lib/FakeAPI.pm82
2 files changed, 9 insertions, 83 deletions
diff --git a/t/03_serialization.t b/t/03_serialization.t
index 333d12e..5fa45c2 100644
--- a/t/03_serialization.t
+++ b/t/03_serialization.t
@@ -2,4 +2,12 @@ use strict;
 use warnings;
 use Test::More;
 
-my $parser = MooseX::Net::API::
+use MooseX::Net::API::Parser::XML;
+use MooseX::Net::API::Parser::JSON;
+use MooseX::Net::API::Parser::YAML;
+
+ok my $xml_parser = MooseX::Net::API::Parser::XML->new();
+ok my $yaml_parser = MooseX::Net::API::Parser::YAML->new();
+ok my $json_parser = MooseX::Net::API::Parser::JSON->new();
+
+done_testing;
diff --git a/t/lib/FakeAPI.pm b/t/lib/FakeAPI.pm
deleted file mode 100644
index 0f53157..0000000
--- a/t/lib/FakeAPI.pm
+++ /dev/null
@@ -1,82 +0,0 @@
-package FakeAPI;
-use Moose;
-use MooseX::Net::API;
-use LWP::UserAgent;
-use HTTP::Response;
-use JSON::XS;
-
-net_api_declare demorest => (
-    base_url => "http://example.com/",
-    format         => 'json',
-    format_mode    => 'content-type',
-    authentication => 0,
-    username       => 'foo',
-    password       => 'bar',
-    useragent      => sub {
-        my ($self) = @_;
-        my $ua = LWP::UserAgent->new();
-        $ua->add_handler(
-            request_send => sub {
-                my $request = shift;
-                my $res = HTTP::Response->new(200, 'OK');
-                $res->header('content-type' => 'application/json');
-                $res->content(encode_json {status => 1});
-                return $res;
-            }
-        );
-        return $ua;
-    },
-);
-
-net_api_method users => (
-    description => 'get a list of users',
-    method      => 'GET',
-    path        => '/users/',
-    expected    => [qw/200/],
-);
-
-net_api_method get_user => (
-    description => 'fetch information about a specific user',
-    method      => 'GET',
-    path        => '/user/$id',
-    params      => [qw/id/],
-    required    => [qw/id/],
-    expected    => [qw/200 404/],
-);
-
-net_api_method create_user => (
-    description => 'create a new user',
-    method      => 'POST',
-    path        => '/user/',
-    params      => [qw/user nickname/],
-    required    => [qw/user nickname/],
-);
-
-net_api_method update_user => (
-    description => 'update information about a specific user',
-    method      => 'PUT',
-    path        => '/user/$id',
-    params      => [qw/id nickname/],
-    required    => [qw/id nickname/],
-);
-
-net_api_method delete_user => (
-    description => 'terminate an user',
-    method      => 'DELETE',
-    path        => '/user/$id',
-    params      => [qw/id/],
-    required    => [qw/id/],
-);
-
-net_api_method auth_get_user => (
-    description =>
-        'fetch information about a specific user with authentication',
-    method         => 'GET',
-    path           => '/auth_user/$id',
-    params         => [qw/id/],
-    required       => [qw/id/],
-    expected       => [qw/200 404/],
-    authentication => 1,
-);
-
-1;