--- lib/PXElator/t/client.t 2009/08/13 13:06:18 216 +++ lib/PXElator/t/client.t 2009/08/13 13:32:19 217 @@ -4,30 +4,34 @@ use strict; use autodie; -use Test::More tests => 9; +use Test::More tests => 13; use Data::Dump qw/dump/; +use English; use_ok 'client'; my $host = '127.0.0.1'; -my $test_path = "$server::base_dir/conf/$server::ip/ip/$host/test"; -unlink $test_path if -e $test_path; +my $mac = 'dead00beef'; + +my $dir = "$server::base_dir/conf/$server::ip"; +system "sudo chown $UID $dir/ip $dir/mac"; ok( client::conf( $host => 'test', default => 'default' ), 'conf default' ); cmp_ok( client::conf( $host => 'test' ), 'eq', 'default', 'default' ); ok( client::conf( $host => 'test' => 'value' ), 'conf set' ); cmp_ok( client::conf( $host => 'test' ), 'eq', 'value', 'value' ); -ok( my $ip = client::next_ip(), 'next_ip' ); +ok( my $ip = client::next_ip( $mac ), 'next_ip' ); diag $ip; -diag "cleanup"; -ok( unlink($test_path), "unlink $test_path" ); -$test_path =~ s{/[^/]+$}{}; -ok( rmdir($test_path), "rmdir $test_path" ); +ok( my $ip_from_mac = client::ip_from_mac( $mac ), 'ip_from_mac' ); +diag $ip_from_mac; +cmp_ok( $ip_from_mac, 'eq', $ip ); + +ok( my $mac_from_ip = client::mac_from_ip( $ip ), 'mac_from_ip' ); +diag $mac_from_ip; +cmp_ok( $mac_from_ip, 'eq', $mac ); -ok( my $ip = client::ip_from_mac( 'AC:DE:48:00:00:00' ), 'ip_from_mac' ); -diag $ip; - -ok( my $mac = client::mac_from_ip( $ip ), 'mac_from_ip' ); -diag $mac; +diag "cleanup"; +ok( unlink( $_ ), "unlink $_" ) foreach ( glob("$dir/ip/$host/*"), "$dir/mac/$mac" ); +ok( rmdir "$dir/ip/$host", 'rmdir' );