summary refs log tree commit diff
path: root/t/02_error.t
blob: 332538a91194e8ec7bff785d84d1f6d5e29f51e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use strict;
use warnings;
use Test::More;
use Test::Exception;

BEGIN {
    dies_ok {
        {

            package net_api_fail;
            use Moose;
            use MooseX::Net::API;
            net_api_declare foo => ();
        }
    }
    "... format is missing";
    like $@, qr/format is missing in your api declaration/,
        "... format is missing";
    dies_ok {
        {

            package net_api_fail;
            use Moose;
            use MooseX::Net::API;
            net_api_declare foo => ( format => 'foo' );
        }
    }
    "... no valid format";
    like $@, qr/format is not recognised/, "... no valid format";
    dies_ok {
        {

            package net_api_fail;
            use Moose;
            use MooseX::Net::API;
            net_api_declare foo => ( format => 'json' );
        }
    }
    "... format mode is not set";
    like $@, qr/format_mode is not set/, "... format mode is not set";
    dies_ok {
        {

            package net_api_fail;
            use Moose;
            use MooseX::Net::API;
            net_api_declare foo => ( format => 'json', format_mode => 'bar' );
        }
    }
    "... format mode is unvalid";
    like $@, qr/must be append or content-type/, "... format mode is unvalid";
    #dies_ok {
        #{
            #package net_api_fail;
            #use Moose;
            #use MooseX::Net::API;
            #net_api_declare foo => (
                #format      => 'json',
                #format_mode => 'content-type'
            #);
        #}
    #}
    #"... bad useragent";
    #warn $@;
}

done_testing;