summary refs log tree commit diff
path: root/t/01_basic.t
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2009-12-20 15:52:22 +0100
committerfranck cuny <franck@lumberjaph.net>2009-12-20 15:52:22 +0100
commitabcc81f7501ac86b528aa5cdabcea26a0049cc27 (patch)
tree1d78c0cb23713aefd655489f18bfb060f1b2ad05 /t/01_basic.t
parentremove and update some tests (diff)
downloadmoosex-net-api-abcc81f7501ac86b528aa5cdabcea26a0049cc27.tar.gz
remove and update some tests
Diffstat (limited to '')
-rw-r--r--t/01_basic.t43
1 files changed, 25 insertions, 18 deletions
diff --git a/t/01_basic.t b/t/01_basic.t
index 471f3dd..3154298 100644
--- a/t/01_basic.t
+++ b/t/01_basic.t
@@ -7,29 +7,36 @@ use FakeAPI;
 
 my $obj = FakeAPI->new;
 ok $obj, "... object created";
-ok $obj->meta->has_attribute('useragent'),
+ok $obj->meta->has_attribute('api_useragent'),
     "... useragent attribute have been added";
 
-ok my $method = $obj->meta->find_method_by_name('bar'),
-    '... method bar have been created';
+ok my $method = $obj->meta->find_method_by_name('get_user'),
+    '... method get_user have been created';
 
 ok $method->meta->has_attribute('path'), '... method bar have attribute path';
-
-throws_ok { $obj->baz } qr/bla is declared as required, but is not present/,
-    "... check required params";
-
-throws_ok {
-    $obj->bar( bar => 1, );
-}
-qr/baz is declared as required, but is not present/,
-    "... check required params are present";
-
-throws_ok {
-    $obj->bar( bar => 1, foo => 2, );
-}
-qr/foo is not declared as a param/, "... check declared params";
+is $method->path, '/user/$id', '... get good path value';
 
 ok my @methods = $obj->meta->local_api_methods(), '... get api methods';
-is scalar @methods, 3, '... got 3 methods in our API';
+is scalar @methods, 6, '... get 6 methods in our API';
+
+ok my $users = $obj->users(), "... get users list";
+is $users->[0]->{user}, "bruce wayne", "... get bruce wayne";
+
+ok my $user = $obj->get_user( id => $users->[0]->{id} ),
+    "... fetch bruce wayne informations";
+is $user->{user}, "bruce wayne", "... get bruce wayne";
+
+dies_ok { $obj->get_user( id => 12 ) } "... can't fetch unknown user";
+my $err = $@;
+is $err->http_code, 404, "... get 404";
+
+my $auth_obj = FakeAPI->new();
+use Try::Tiny;
+use YAML::Syck;
+try {
+    my $res = $auth_obj->auth_get_user(id => 1);
+}catch{
+    warn Dump $_;
+};
 
 done_testing;