4 use Test::More tests => 10;
7 my $schema = DBICTest->init_schema();
9 my $host_rs = $schema->resultset('Host');
11 my $localhost = $host_rs->find('localhost');
13 isa_ok($localhost->address, 'NetAddr::IP', 'numeric address inflated to right class');
14 is($localhost->address, '127.0.0.1/32', 'numeric address correctly inflated');
17 skip "DBIx::Class doesn't support find by object yet" => 1;
19 $localhost = $host_rs->find(NetAddr::IP->new('127.0.0.1'), { key => 'address' });
21 ok($localhost, 'find by object returned a row');
25 skip 'no object to check' => 1 unless $localhost;
27 is($localhost->hostname, 'localhost', 'find by object returned the right row');
30 my $ip = NetAddr::IP->new('192.168.0.1');
31 my $host = $host_rs->create({ hostname => 'foo', address => $ip });
33 isa_ok($host, 'DBICTest::Schema::Host', 'create with object');
34 is($host->get_column('address'), $ip->numeric, 'numeric address correctly deflated');
36 my $net_rs = $schema->resultset('Network');
38 my $localnet = $net_rs->find('localnet');
40 isa_ok($localnet->address, 'NetAddr::IP', 'CIDR address inflated to right class');
41 is($localnet->address, '127.0.0.0/8', 'CIDR address correctly inflated');
43 my $net_ip = NetAddr::IP->new('192.168.0.42/24');
44 my $net = $net_rs->create({ netname => 'foo', address => $net_ip });
46 isa_ok($net, 'DBICTest::Schema::Network', 'create with object');
47 is($net->get_column('address'), '192.168.0.42/24', 'CIDR address correctly deflated');