1use strict;
2use warnings;
3use Test::More;
4use Test::MockObject;
5use Test::MockObject::Extends;
6use Net::Gnats;
7
8use File::Basename;
9use lib dirname(__FILE__);
10use Net::Gnats::TestData::Gtdata qw(connect_standard_wauth);
11
12my $module = Test::MockObject::Extends->new('IO::Socket::INET');
13$module->fake_new( 'IO::Socket::INET' );
14$module->set_true( 'print' );
15$module->set_series( 'getline',
16                     @{ connect_standard_wauth() },
17                     # not issued
18                     "350 A default value\r\n",
19                     "350-A default value for field1\r\n",
20                     "350 A default value for field2\r\n",
21                     "350 A default value\r\n",
22                     "350-A default value for field1\r\n",
23                     "350 A default value for field2\r\n",
24                   );
25
26my $g = Net::Gnats::Session->new(username => 'madmin', password => 'madmin');
27$g->gconnect;
28
29my $c1 = Net::Gnats::Command->inputdefault;
30my $c2 = Net::Gnats::Command->inputdefault(fields => ['field']);
31my $c3 = Net::Gnats::Command->inputdefault(fields => ['field1', 'field2']);
32
33is $g->issue($c1)->is_ok, 0, 'c1 is NOT OK';
34is $g->issue($c2)->is_ok, 1, 'c2 is OK';
35is $g->issue($c3)->is_ok, 1, 'c3 is OK';
36
37is_deeply $g->issue($c2)->response->as_list, ['A default value'], 'c2 list is OK';
38is_deeply $g->issue($c3)->response->as_list, ['A default value for field1','A default value for field2'], 'c3 list is OK';
39
40done_testing();
41