]>
Dogcows Code - chaz/graphql-client/blob - t/cli.t
9 use GraphQL
::Client
::CLI
;
11 delete $ENV{GRAPHQL_CLIENT_OPTIONS
};
13 subtest
'get_options' => sub {
15 format
=> 'json:pretty',
19 operation_name
=> undef,
29 my $r = GraphQL
::Client
::CLI-
>_get_options(qw{--url foo --query bar});
30 is_deeply
($r, $expected, '--url and --query set options') or diag explain
$r;
32 $r = GraphQL
::Client
::CLI-
>_get_options(qw{foo --query bar});
33 is_deeply
($r, $expected, '--url is optional') or diag explain
$r;
35 $r = GraphQL
::Client
::CLI-
>_get_options(qw{foo bar});
36 is_deeply
($r, $expected, '--query is also optional') or diag explain
$r;
39 local $ENV{GRAPHQL_CLIENT_OPTIONS
} = '--url asdf --query "baz qux" --unpack';
40 local $expected->{query
} = 'baz qux';
41 local $expected->{unpack} = 1;
42 $r = GraphQL
::Client
::CLI-
>_get_options(qw{--url foo});
43 is_deeply
($r, $expected, 'options can come from GRAPHQL_CLIENT_OPTIONS') or diag explain
$r;
47 subtest
'get_options_transport' => sub {
49 format
=> 'json:pretty',
53 operation_name
=> undef,
56 transport
=> { headers
=> {'X-Test' => 'value', 'X-Test-2' => 'val2' } },
63 my $r = GraphQL
::Client
::CLI-
>_get_options(qw{--url foo --query bar --transport headers.X-Test=value --transport headers.X-Test-2=val2});
64 is_deeply
($r, $expected, '--url, --query set option and correctly expanded transport options') or diag explain
$r;
70 subtest
'expand_vars' => sub {
71 my $r = GraphQL
::Client
::CLI
::_expand_vars
({
74 'arr1[1].tut' => 'whatever',
75 'arr2[1][0].meh'=> 3.1415,
98 }, 'expand all the vars') or diag explain
$r;
101 GraphQL
::Client
::CLI
::_expand_vars
({
105 } qr/^Conflicting keys/, 'throw if conflict between hash and array';
108 GraphQL
::Client
::CLI
::_expand_vars
({
112 } qr/^Conflicting keys/, 'throw if conflict between hash and scalar';
This page took 0.043329 seconds and 4 git commands to generate.