1use strict; 2use warnings; 3use Test::More; 4use Test::MockObject; 5use Test::MockObject::Extends; 6use Net::Gnats qw(verbose verbose_level); 7use Net::Gnats::Schema; 8use Net::Gnats::Session; 9 10Net::Gnats->verbose(1); 11Net::Gnats->verbose_level(1); 12 13use File::Basename; 14use lib dirname(__FILE__); 15use Net::Gnats::TestData::Gtdata qw(connect_standard conn user schema1); 16 17my $module = Test::MockObject::Extends->new('IO::Socket::INET'); 18$module->fake_new( 'IO::Socket::INET' ); 19$module->set_true( 'print' ); 20$module->set_series( 'getline', 21 @{ conn() }, 22 @{ user() }, 23 "210-Now accessing GNATS database 'default'\r\n", 24 "210 User access level set to 'admin'\r\n", 25 @{ schema1() } 26 ); 27 28my $g = Net::Gnats->new(); 29print "Connecting\n"; 30$g->gnatsd_connect; 31$g->login('default', 'madmin', 'madmin'); 32 33# initialize new schema 34print "init schema\n"; 35isa_ok my $s = $g->session->schema, 'Net::Gnats::Schema'; 36 37print "lookup field\n"; 38is $s->field('Synopsis')->name, 'Synopsis'; 39is $s->field('Synopsis')->description, 'One-line summary of the PR'; 40is $s->field('Synopsis')->type, 'Text'; 41is $s->field('Synopsis')->default, ''; 42is $s->field('Synopsis')->flags, 'textsearch '; 43 44is $s->field('Number')->name, 'Number'; 45is $s->field('Number')->description, 'PR Number'; 46is $s->field('Number')->type, 'Integer'; 47is $s->field('Number')->default, '-1'; 48is $s->field('Number')->flags, 'readonly '; 49 50done_testing(); 51