From: jwright Date: Tue, 29 Mar 2022 21:15:59 +0000 (-0400) Subject: otions.transport not set to expanded var form X-Git-Tag: v0.605~2^2 X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=78fe43f3b6b2dc9f9b8222a4926cad5dfd9e2a8c;p=chaz%2Fgraphql-client otions.transport not set to expanded var form --- diff --git a/lib/GraphQL/Client/CLI.pm b/lib/GraphQL/Client/CLI.pm index c23e07f..8ddc78f 100644 --- a/lib/GraphQL/Client/CLI.pm +++ b/lib/GraphQL/Client/CLI.pm @@ -138,6 +138,7 @@ sub _get_options { my $transport = eval { _expand_vars($options{transport}) }; die "Two or more --transport keys are incompatible.\n" if $@; + $options{transport} = $transport if ref $transport eq 'HASH' && %$transport; if (ref $options{variables}) { $options{variables} = eval { _expand_vars($options{variables}) }; diff --git a/t/cli.t b/t/cli.t index a32af83..142f2e5 100755 --- a/t/cli.t +++ b/t/cli.t @@ -44,6 +44,29 @@ subtest 'get_options' => sub { } }; +subtest 'get_options_transport' => sub { + my $expected = { + format => 'json:pretty', + filter => undef, + help => undef, + manual => undef, + operation_name => undef, + outfile => undef, + query => 'bar', + transport => { headers => {'X-Test' => 'value', 'X-Test-2' => 'val2' } }, + unpack => 0, + url => 'foo', + variables => undef, + version => undef, + }; + + my $r = GraphQL::Client::CLI->_get_options(qw{--url foo --query bar --transport headers.X-Test=value --transport headers.X-Test-2=val2}); + is_deeply($r, $expected, '--url, --query set option and correctly expanded transport options') or diag explain $r; +}; + + + + subtest 'expand_vars' => sub { my $r = GraphQL::Client::CLI::_expand_vars({ 'foo.bar' => 'baz',