/[pxelator]/lib/PXElator/t/client.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/PXElator/t/client.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 200 by dpavlin, Tue Aug 11 15:55:26 2009 UTC revision 443 by dpavlin, Tue Sep 29 19:28:24 2009 UTC
# Line 4  use warnings; Line 4  use warnings;
4  use strict;  use strict;
5  use autodie;  use autodie;
6    
7  use Test::More tests => 9;  use Test::More tests => 22;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9    use English;
10    
11  use_ok 'client';  use_ok 'client';
12    
13  my $host = '127.0.0.1';  my $host = '127.0.0.1';
14  my $test_path = "$server::base_dir/conf/$server::ip/ip/$host/test";  my $mac  = 'DE:AD:00:00:BE:EF';
15  unlink $test_path if -e $test_path;  
16    my $dir = "$server::base_dir/conf";
17    system "sudo chown $UID $dir/ip $dir/mac";
18    
19  ok( client::conf( $host => 'test', default => 'default' ), 'conf default' );  ok( client::conf( $host => 'test', default => 'default' ), 'conf default' );
20  cmp_ok( client::conf( $host => 'test' ), 'eq', 'default', 'default' );  cmp_ok( client::conf( $host => 'test' ), 'eq', 'default', 'default' );
21  ok( client::conf( $host => 'test' => 'value' ), 'conf set' );  ok( client::conf( $host => 'test' => 'value' ), 'conf set' );
22  cmp_ok( client::conf( $host => 'test' ), 'eq', 'value', 'value' );  cmp_ok( client::conf( $host => 'test' ), 'eq', 'value', 'value' );
23    
24  ok( my $ip = client::next_ip(), 'next_ip' );  ok( client::conf( $host => 'dir/test' => 'in_dir' ), 'conf test/dir' );
25  diag $ip;  cmp_ok( client::conf( $host => 'dir/test' ), 'eq', 'in_dir', 'value' );
26    
27    ok( ! client::conf( $host => 'non-existing' ), 'conf non-existing' );
28    
29  diag "cleanup";  ok( client::remove( $host ), "remove $host" );
 ok( unlink($test_path), "unlink $test_path" );  
 $test_path =~ s{/[^/]+$}{};  
 ok( rmdir($test_path), "rmdir $test_path" );  
30    
31  ok( my $ip = client::ip_from_mac( 'AC:DE:48:00:00:00' ), 'ip_from_mac' );  ok( my $ip = client::next_ip( $mac ), 'next_ip' );
32  diag $ip;  diag $ip;
33    
34  ok( my $mac = client::mac_from_ip( $ip ), 'mac_from_ip' );  ok( my $ip_from_mac = client::ip_from_mac( $mac ), 'ip_from_mac' );
35  diag $mac;  diag $ip_from_mac;
36    cmp_ok( $ip_from_mac, 'eq', $ip );
37    
38    ok( my $mac_from_ip = client::mac_from_ip( $ip ), 'mac_from_ip' );
39    diag $mac_from_ip;
40    cmp_ok( $mac_from_ip, 'eq', $mac );
41    
42    ok( my $conf = client::all_conf( $ip ), 'all_conf' );
43    diag dump $conf;
44    
45    ok( my @ips = client::all_ips(), 'all_ips' );
46    diag dump @ips;
47    
48    ok( my $new_ip = client::change_ip( $ip, $host ), 'change_ip' );
49    ok( ! client::change_ip( $new_ip, $new_ip ), 'change_ip without change' );
50    ok( my $old_ip = client::change_ip( $new_ip, $ip ), 'change_ip back' );
51    cmp_ok( $old_ip, 'eq', $ip, 'ip back' );
52    
53    ok( client::arp_mac_dev(), 'arp_mac_dev' );
54    
55    ok( client::remove( $ip ), "remove $ip" );

Legend:
Removed from v.200  
changed lines
  Added in v.443

  ViewVC Help
Powered by ViewVC 1.1.26