]> Dogcows Code - chaz/graphql-client/blobdiff - t/cli.t
Release GraphQL-Client 0.605
[chaz/graphql-client] / t / cli.t
diff --git a/t/cli.t b/t/cli.t
index 2ae980e4f0a76e55785ba01d8da9fd56ff1bd404..142f2e5ad37979fcb045da8bb728c4d6adc48c8f 100755 (executable)
--- a/t/cli.t
+++ b/t/cli.t
@@ -8,9 +8,12 @@ use Test::More;
 
 use GraphQL::Client::CLI;
 
+delete $ENV{GRAPHQL_CLIENT_OPTIONS};
+
 subtest 'get_options' => sub {
     my $expected = {
         format          => 'json:pretty',
+        filter          => undef,
         help            => undef,
         manual          => undef,
         operation_name  => undef,
@@ -31,8 +34,39 @@ subtest 'get_options' => sub {
 
     $r = GraphQL::Client::CLI->_get_options(qw{foo bar});
     is_deeply($r, $expected, '--query is also optional') or diag explain $r;
+
+    {
+        local $ENV{GRAPHQL_CLIENT_OPTIONS} = '--url asdf --query "baz qux" --unpack';
+        local $expected->{query} = 'baz qux';
+        local $expected->{unpack} = 1;
+        $r = GraphQL::Client::CLI->_get_options(qw{--url foo});
+        is_deeply($r, $expected, 'options can come from GRAPHQL_CLIENT_OPTIONS') or diag explain $r;
+    }
+};
+
+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',
This page took 0.02048 seconds and 4 git commands to generate.