]>
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
'expand_vars' => sub {
48 my $r = GraphQL
::Client
::CLI
::_expand_vars
({
51 'arr1[1].tut' => 'whatever',
52 'arr2[1][0].meh'=> 3.1415,
75 }, 'expand all the vars') or diag explain
$r;
78 GraphQL
::Client
::CLI
::_expand_vars
({
82 } qr/^Conflicting keys/, 'throw if conflict between hash and array';
85 GraphQL
::Client
::CLI
::_expand_vars
({
89 } qr/^Conflicting keys/, 'throw if conflict between hash and scalar';
This page took 0.038616 seconds and 4 git commands to generate.