]>
Dogcows Code - chaz/graphql-client/blob - t/cli.t
2fa501ceac917a4f2dc88bac39e0d127ea579208
9 use GraphQL
::Client
::CLI
;
11 delete $ENV{GRAPHQL_CLIENT_OPTIONS
};
13 subtest
'get_options' => sub {
15 format
=> 'json:pretty',
18 operation_name
=> undef,
28 my $r = GraphQL
::Client
::CLI-
>_get_options(qw{--url foo --query bar});
29 is_deeply
($r, $expected, '--url and --query set options') or diag explain
$r;
31 $r = GraphQL
::Client
::CLI-
>_get_options(qw{foo --query bar});
32 is_deeply
($r, $expected, '--url is optional') or diag explain
$r;
34 $r = GraphQL
::Client
::CLI-
>_get_options(qw{foo bar});
35 is_deeply
($r, $expected, '--query is also optional') or diag explain
$r;
38 local $ENV{GRAPHQL_CLIENT_OPTIONS
} = '--url asdf --query "baz qux" --unpack';
39 local $expected->{query
} = 'baz qux';
40 local $expected->{unpack} = 1;
41 $r = GraphQL
::Client
::CLI-
>_get_options(qw{--url foo});
42 is_deeply
($r, $expected, 'options can come from GRAPHQL_CLIENT_OPTIONS') or diag explain
$r;
46 subtest
'expand_vars' => sub {
47 my $r = GraphQL
::Client
::CLI
::_expand_vars
({
50 'arr1[1].tut' => 'whatever',
51 'arr2[1][0].meh'=> 3.1415,
74 }, 'expand all the vars') or diag explain
$r;
77 GraphQL
::Client
::CLI
::_expand_vars
({
81 } qr/^Conflicting keys/, 'throw if conflict between hash and array';
84 GraphQL
::Client
::CLI
::_expand_vars
({
88 } qr/^Conflicting keys/, 'throw if conflict between hash and scalar';
This page took 0.041276 seconds and 3 git commands to generate.