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 "210 GNATS database is now unlocked.\r\n", 18 "600 CODE_CMD_ERROR\r\n", 19 "440 CODE_CMD_ERROR\r\n", 20 "431 CODE_GNATS_LOCKED\r\n", 21 ); 22 23my $g = Net::Gnats::Session->new(username => 'madmin', password => 'madmin')->gconnect; 24 25my $c1 = Net::Gnats::Command->undb; 26 27is $g->issue($c1)->is_ok, 1, 'c1 is OK'; 28is $g->issue($c1)->is_ok, 0, 'c1 is NOT OK'; 29is $g->issue($c1)->is_ok, 0, 'c1 is NOT OK'; 30is $g->issue($c1)->is_ok, 0, 'c1 is NOT OK'; 31 32 33# is( $g->unlock_main_database, 1, '210 locked' ); 34# is( $g->unlock_main_database, 0, 'ERROR 600 Can lock database' ); 35# is( $g->unlock_main_database, 0, 'CODE_CMD_ERROR'); 36# is( $g->unlock_main_database, 0, 'CODE_CMD_ERROR'); 37 38done_testing(); 39