summary refs log tree commit diff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/01_basic.t35
-rw-r--r--t/lib/TestAPI.pm16
2 files changed, 51 insertions, 0 deletions
diff --git a/t/01_basic.t b/t/01_basic.t
index d21e930..0958c36 100644
--- a/t/01_basic.t
+++ b/t/01_basic.t
@@ -93,4 +93,39 @@ $api->api_useragent->add_handler(
 
 ($content, $res) = $api->delete_user(name => 'eris');
 is $res->code, 204, 'code as expected';
+
+# unstrict parameters
+$api->api_useragent->remove_handler('request_send');
+$api->api_useragent->add_handler(
+    'request_send' => sub {
+        my $request = shift;
+        my $res = HTTP::Response->new(200);
+        $res;
+    }
+);
+
+($content, $res) = $api->unstrict_users(
+    name         => 'eris',
+    last_name    => 'foo',
+    random_stuff => 'bar'
+);
+is $res->code, 200, 'code as expected';
+is $res->request->uri,
+  'http://exemple.com/users/unstrict.json?random_stuff=bar&name=eris&last_name=foo',
+  'url is ok with no declared parameters';
+
+# params in url and body
+$api->api_useragent->remove_handler('request_send');
+$api->api_useragent->add_handler(
+    'request_send' => sub {
+        my $request = shift;
+        my $res = HTTP::Response->new(200);
+        $res;
+    }
+);
+
+($content, $res) = $api->params_users(name => 'eris', bod => '01/01/1970');
+is $res->code, 200, 'code as expected';
+is $res->request->uri, 'http://exemple.com/users.json?bod=01%2F01%2F1970', 'url is ok';
+
 done_testing;
diff --git a/t/lib/TestAPI.pm b/t/lib/TestAPI.pm
index a2aed55..45d3cb2 100644
--- a/t/lib/TestAPI.pm
+++ b/t/lib/TestAPI.pm
@@ -46,4 +46,20 @@ net_api_method delete_user => (
     expected => [qw/204/],
 );
 
+net_api_method unstrict_users => (
+    method   => 'GET',
+    path     => '/users/unstrict',
+    strict   => 0,
+    params   => [qw/name/],
+    required => [qw/name/],
+);
+
+net_api_method params_users => (
+    method        => 'POST',
+    path          => '/users/',
+    params        => [qw/name/],
+    params_in_url => [qw/bod/],
+    required      => [qw/bod name/],
+);
+
 1;