From a0ce0340d0f95514008cfac751fe58748bbadd88 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 20 Mar 2008 00:04:16 +0000 Subject: * Switched indent used in Perl-code and settings files from tabs to 4 spaces. May need some manual corrections here and there, but should basically be ok. git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1658 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/t/13-client.t | 298 ++++++++++++++++++++++++------------------------ 1 file changed, 149 insertions(+), 149 deletions(-) (limited to 'config-db/t/13-client.t') diff --git a/config-db/t/13-client.t b/config-db/t/13-client.t index 1c8ea99f..c9c77db9 100644 --- a/config-db/t/13-client.t +++ b/config-db/t/13-client.t @@ -12,96 +12,96 @@ my $configDB = OpenSLX::ConfigDB->new; $configDB->connect(); ok( - my $client = $configDB->fetchClientByFilter, - 'one client [default] should exist (scalar context)' + my $client = $configDB->fetchClientByFilter, + 'one client [default] should exist (scalar context)' ); foreach my $requiredCol (qw(name mac)) { - my $wrongClient = { - 'name' => 'name', - 'mac' => '01:02:03:04:05:06', - 'comment' => 'has column missing', - }; - delete $wrongClient->{$requiredCol}; - ok( - ! eval { my $clientID = $configDB->addClient($wrongClient); }, - "inserting a client without '$requiredCol' column should fail" - ); + my $wrongClient = { + 'name' => 'name', + 'mac' => '01:02:03:04:05:06', + 'comment' => 'has column missing', + }; + delete $wrongClient->{$requiredCol}; + ok( + ! eval { my $clientID = $configDB->addClient($wrongClient); }, + "inserting a client without '$requiredCol' column should fail" + ); } is( - my @clients = $configDB->fetchClientByFilter, 1, - 'still just one client [default] should exist (array context)' + my @clients = $configDB->fetchClientByFilter, 1, + 'still just one client [default] should exist (array context)' ); my $inClient1 = { - 'name' => 'cli-1', - 'mac' => '01:02:03:04:05:01', - 'comment' => '', - 'attrs' => { - 'slxgrp' => 'slxgrp', - 'start_snmp' => 'no', - 'start_sshd' => 'yes', - }, + 'name' => 'cli-1', + 'mac' => '01:02:03:04:05:01', + 'comment' => '', + 'attrs' => { + 'slxgrp' => 'slxgrp', + 'start_snmp' => 'no', + 'start_sshd' => 'yes', + }, }; is( - my $client1ID = $configDB->addClient($inClient1), 1, - 'first client has ID 1' + my $client1ID = $configDB->addClient($inClient1), 1, + 'first client has ID 1' ); my $inClient2 = { - 'name' => 'cli-2.0', - 'unbootable' => 1, - 'mac' => '01:02:03:04:05:02', - 'comment' => undef, - 'boot_type' => 'etherboot', + 'name' => 'cli-2.0', + 'unbootable' => 1, + 'mac' => '01:02:03:04:05:02', + 'comment' => undef, + 'boot_type' => 'etherboot', }; my $fullClient = { - 'name' => 'cli-nr-3', - 'mac' => '01:02:03:04:05:03', - 'comment' => 'nuff said', - 'kernel_params' => 'debug=3 console=ttyS1', - 'unbootable' => '0', - 'boot_type' => 'pxe', - 'attrs' => { - 'automnt_dir' => 'a', - 'automnt_src' => 'b', - 'country' => 'c', - 'dm_allow_shutdown' => 'd', - 'hw_graphic' => 'e', - 'hw_monitor' => 'f', - 'hw_mouse' => 'g', - 'late_dm' => 'h', - 'netbios_workgroup' => 'i', - 'nis_domain' => 'j', - 'nis_servers' => 'k', - 'sane_scanner' => 'p', - 'scratch' => 'q', - 'slxgrp' => 'r', - 'start_alsasound' => 's', - 'start_atd' => 't', - 'start_cron' => 'u', - 'start_dreshal' => 'v', - 'start_ntp' => 'w', - 'start_nfsv4' => 'x', - 'start_printer' => 'y', - 'start_samba' => 'z', - 'start_snmp' => 'A', - 'start_sshd' => 'B', - 'start_syslog' => 'C', - 'start_x' => 'D', - 'start_xdmcp' => 'E', - 'tex_enable' => 'F', - 'timezone' => 'G', - 'tvout' => 'H', - 'vmware' => 'I', - }, + 'name' => 'cli-nr-3', + 'mac' => '01:02:03:04:05:03', + 'comment' => 'nuff said', + 'kernel_params' => 'debug=3 console=ttyS1', + 'unbootable' => '0', + 'boot_type' => 'pxe', + 'attrs' => { + 'automnt_dir' => 'a', + 'automnt_src' => 'b', + 'country' => 'c', + 'dm_allow_shutdown' => 'd', + 'hw_graphic' => 'e', + 'hw_monitor' => 'f', + 'hw_mouse' => 'g', + 'late_dm' => 'h', + 'netbios_workgroup' => 'i', + 'nis_domain' => 'j', + 'nis_servers' => 'k', + 'sane_scanner' => 'p', + 'scratch' => 'q', + 'slxgrp' => 'r', + 'start_alsasound' => 's', + 'start_atd' => 't', + 'start_cron' => 'u', + 'start_dreshal' => 'v', + 'start_ntp' => 'w', + 'start_nfsv4' => 'x', + 'start_printer' => 'y', + 'start_samba' => 'z', + 'start_snmp' => 'A', + 'start_sshd' => 'B', + 'start_syslog' => 'C', + 'start_x' => 'D', + 'start_xdmcp' => 'E', + 'tex_enable' => 'F', + 'timezone' => 'G', + 'tvout' => 'H', + 'vmware' => 'I', + }, }; ok( - my ($client2ID, $client3ID) = $configDB->addClient([ - $inClient2, $fullClient - ]), - 'add two more clients' + my ($client2ID, $client3ID) = $configDB->addClient([ + $inClient2, $fullClient + ]), + 'add two more clients' ); is($client2ID, 2, 'client 2 should have ID=2'); is($client3ID, 3, 'client 3 should have ID=3'); @@ -150,8 +150,8 @@ is(keys %{$client3->{attrs}}, 31, 'client 3 - attribu # fetch client 2 by a filter on id and check all values ok( - my $client2 = $configDB->fetchClientByFilter({ id => 2 }), - 'fetch client 2 by filter on id' + my $client2 = $configDB->fetchClientByFilter({ id => 2 }), + 'fetch client 2 by filter on id' ); is($client2->{id}, 2, 'client 2 - id'); is($client2->{name}, 'cli-2.0', 'client 2 - name'); @@ -163,8 +163,8 @@ is(keys %{$client2->{attrs}}, 0, 'client 2 - attribute count') # fetch client 1 by filter on name and check all values ok( - my $client1 = $configDB->fetchClientByFilter({ name => 'cli-1' }), - 'fetch client 1 by filter on name' + my $client1 = $configDB->fetchClientByFilter({ name => 'cli-1' }), + 'fetch client 1 by filter on name' ); is($client1->{id}, 1, 'client 1 - id'); is($client1->{name}, 'cli-1', 'client 1 - name'); @@ -180,8 +180,8 @@ is($client1->{attrs}->{start_sshd}, 'yes', 'client 1 - attr start_sshd') # fetch clients 3 & 1 by id ok( - my @clients3And1 = $configDB->fetchClientByID([3, 1]), - 'fetch clients 3 & 1 by id' + my @clients3And1 = $configDB->fetchClientByID([3, 1]), + 'fetch clients 3 & 1 by id' ); is(@clients3And1, 2, 'should have got 2 clients'); # now sort by ID and check if we have really got 3 and 1 @@ -191,21 +191,21 @@ is($clients3And1[1]->{id}, 3, 'second id should be 3'); # fetching clients by id without giving any should yield undef is( - $configDB->fetchClientByID(), undef, - 'fetch clients by id without giving any' + $configDB->fetchClientByID(), undef, + 'fetch clients by id without giving any' ); # fetching clients by filter without giving any should yield all of them ok( - @clients = $configDB->fetchClientByFilter(), - 'fetch clients by filter without giving any' + @clients = $configDB->fetchClientByFilter(), + 'fetch clients by filter without giving any' ); is(@clients, 4, 'should have got all four clients'); # fetch clients 1 & 2 by filter on boot_type ok( - my @clients1And3 = $configDB->fetchClientByFilter({ boot_type => 'pxe' }), - 'fetch clients 1 & 3 by filter on boot_type' + my @clients1And3 = $configDB->fetchClientByFilter({ boot_type => 'pxe' }), + 'fetch clients 1 & 3 by filter on boot_type' ); is(@clients1And3, 2, 'should have got 2 clients'); # now sort by ID and check if we have really got 1 and 3 @@ -215,17 +215,17 @@ is($clients1And3[1]->{id}, 3, 'second id should be 3'); # try to fetch with multi-column filter ok( - ($client1, $client3) - = $configDB->fetchClientByFilter({ boot_type => 'pxe', id => 1 }), - 'fetching client with boot_type=pxe and id=1 should work' + ($client1, $client3) + = $configDB->fetchClientByFilter({ boot_type => 'pxe', id => 1 }), + 'fetching client with boot_type=pxe and id=1 should work' ); is($client1->{name}, 'cli-1', 'should have got cli-1'); is($client3, undef, 'should not get cli-nr-3'); # fetch client 1 by filter on unbootable being undef'd ok( - my @client1Only = $configDB->fetchClientByFilter({ unbootable => undef }), - 'fetch client 1 by filter on unbootable being undefined' + my @client1Only = $configDB->fetchClientByFilter({ unbootable => undef }), + 'fetch client 1 by filter on unbootable being undefined' ); is(@client1Only, 1, 'should have got 1 client'); is($client1Only[0]->{id}, 1, 'first id should be 1'); @@ -233,8 +233,8 @@ is($client1Only[0]->{id}, 1, 'first id should be 1'); # try to fetch multiple occurrences of the same client, combined with # some unknown IDs ok( - @clients1And3 = $configDB->fetchClientByID([ 1, 21, 4-1, 1, 4, 1, 1 ]), - 'fetch a complex set of clients by ID' + @clients1And3 = $configDB->fetchClientByID([ 1, 21, 4-1, 1, 4, 1, 1 ]), + 'fetch a complex set of clients by ID' ); is(@clients1And3, 2, 'should have got 2 clients'); # now sort by ID and check if we have really got 1 and 3 @@ -244,74 +244,74 @@ is($clients1And3[1]->{id}, 3, 'second id should be 3'); # filter clients by different attributes & values in combination ok( - @client1Only = $configDB->fetchClientByFilter( {}, undef, { - start_snmp => 'no', - } ), - 'fetch client 1 by filter on attribute start_snmp' + @client1Only = $configDB->fetchClientByFilter( {}, undef, { + start_snmp => 'no', + } ), + 'fetch client 1 by filter on attribute start_snmp' ); is(@client1Only, 1, 'should have got 1 client'); is($client1Only[0]->{id}, 1, 'first id should be 1'); ok( - @client1Only = $configDB->fetchClientByFilter( undef, 'id', { - start_snmp => 'no', - tex_enable => undef, - } ), - 'fetch client 1 by filter on attribute start_snmp + non-existing attr' + @client1Only = $configDB->fetchClientByFilter( undef, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch client 1 by filter on attribute start_snmp + non-existing attr' ); is(@client1Only, 1, 'should have got 1 client'); is($client1Only[0]->{id}, 1, 'first id should be 1'); ok( - @client1Only = $configDB->fetchClientByFilter( { - name => 'cli-1', - unbootable => undef, - }, 'id', { - start_snmp => 'no', - tex_enable => undef, - } ), - 'fetch client 1 by multiple filter on values and attributes' + @client1Only = $configDB->fetchClientByFilter( { + name => 'cli-1', + unbootable => undef, + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch client 1 by multiple filter on values and attributes' ); is(@client1Only, 1, 'should have got 1 client'); is($client1Only[0]->{id}, 1, 'first id should be 1'); is( - $configDB->fetchClientByFilter( { - comment => 'xxx', - }, 'id', { - start_snmp => 'no', - tex_enable => undef, - } ), - undef, - 'mismatch client 1 by filter with incorrect value' + $configDB->fetchClientByFilter( { + comment => 'xxx', + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + undef, + 'mismatch client 1 by filter with incorrect value' ); is( - $configDB->fetchClientByFilter( { - name => 'cli-1', - }, 'id', { - start_snmp => 'yes', - tex_enable => undef, - } ), - undef, - 'mismatch client 1 by filter with incorrect attribute value' + $configDB->fetchClientByFilter( { + name => 'cli-1', + }, 'id', { + start_snmp => 'yes', + tex_enable => undef, + } ), + undef, + 'mismatch client 1 by filter with incorrect attribute value' ); is( - $configDB->fetchClientByFilter( { - name => 'cli-1', - }, 'id', { - start_sshd => undef, - } ), - undef, - 'mismatch client 1 by filter with attribute not being empty' + $configDB->fetchClientByFilter( { + name => 'cli-1', + }, 'id', { + start_sshd => undef, + } ), + undef, + 'mismatch client 1 by filter with attribute not being empty' ); # fetch clients 0, 1 & 2 by filter on attribute start_samba not existing ok( - my @clients01And2 = $configDB->fetchClientByFilter( {}, undef, { - start_samba => undef, - } ), - 'fetch clients 0,1 & 2 by filter on attribute start_samba not existing' + my @clients01And2 = $configDB->fetchClientByFilter( {}, undef, { + start_samba => undef, + } ), + 'fetch clients 0,1 & 2 by filter on attribute start_samba not existing' ); is(@clients01And2, 3, 'should have got 3 clients'); # now sort by ID and check if we have really got 0, 1 and 2 @@ -322,34 +322,34 @@ is($clients01And2[2]->{id}, 2, 'third id should be 2'); # try to fetch a couple of non-existing clients by id is( - $configDB->fetchClientByID(-1), undef, - 'client with id -1 should not exist' + $configDB->fetchClientByID(-1), undef, + 'client with id -1 should not exist' ); ok($configDB->fetchClientByID(0), 'client with id 0 should exist'); is( - $configDB->fetchClientByID(1 << 31 + 1000), undef, - 'trying to fetch another unknown client' + $configDB->fetchClientByID(1 << 31 + 1000), undef, + 'trying to fetch another unknown client' ); # try to fetch a couple of non-existing clients by filter is( - $configDB->fetchClientByFilter({ id => 4 }), undef, - 'fetching client with id=4 by filter should fail' + $configDB->fetchClientByFilter({ id => 4 }), undef, + 'fetching client with id=4 by filter should fail' ); is( - $configDB->fetchClientByFilter({ name => 'cli-1.x' }), undef, - 'fetching client with name="cli-1.x" should fail' + $configDB->fetchClientByFilter({ name => 'cli-1.x' }), undef, + 'fetching client with name="cli-1.x" should fail' ); is( - $configDB->fetchClientByFilter({ mac => '01:01:01:01:01:01', id => 1 }), undef, - 'fetching client with mac=01:01:01:01:01:01 and id=1 should fail' + $configDB->fetchClientByFilter({ mac => '01:01:01:01:01:01', id => 1 }), undef, + 'fetching client with mac=01:01:01:01:01:01 and id=1 should fail' ); # rename client 1 and then fetch it by its new name ok($configDB->changeClient(1, { name => q{CLI-'1'} }), 'changing client 1'); ok( - $client1 = $configDB->fetchClientByFilter({ name => q{CLI-'1'} }), - 'fetching renamed client 1' + $client1 = $configDB->fetchClientByFilter({ name => q{CLI-'1'} }), + 'fetching renamed client 1' ); is($client1->{id}, 1, 'really got client number 1'); is($client1->{name}, q{CLI-'1'}, q{really got client named "CLI-'1'"}); @@ -386,8 +386,8 @@ ok(!exists $client1->{attrs}->{vmware}, 'attr vmware should be gone'); # changing a non-existing column should fail ok( - ! eval { $configDB->changeClient(1, { xname => "xx" }) }, - 'changing unknown colum should fail' + ! eval { $configDB->changeClient(1, { xname => "xx" }) }, + 'changing unknown colum should fail' ); ok(! $configDB->changeClient(1, { id => 23 }), 'changing id should fail'); -- cgit v1.2.3-55-g7522