diff options
Diffstat (limited to 'config-db/t/11-export.t')
-rw-r--r-- | config-db/t/11-export.t | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/config-db/t/11-export.t b/config-db/t/11-export.t index 0cdc688c..3dd0ae6c 100644 --- a/config-db/t/11-export.t +++ b/config-db/t/11-export.t @@ -12,70 +12,70 @@ my $configDB = OpenSLX::ConfigDB->new; $configDB->connect(); is( - my $export = $configDB->fetchExportByFilter, undef, - 'no export yet (scalar context)' + my $export = $configDB->fetchExportByFilter, undef, + 'no export yet (scalar context)' ); foreach my $requiredCol (qw(name vendor_os_id type)) { - my $wrongExport = { - 'name' => 'name', - 'vendor_os_id' => 1, - 'type ' => 'nfs', - 'comment' => 'has column missing', - }; - delete $wrongExport->{$requiredCol}; - ok( - ! eval { my $exportID = $configDB->addExport($wrongExport); }, - "inserting an export without '$requiredCol' column should fail" - ); + my $wrongExport = { + 'name' => 'name', + 'vendor_os_id' => 1, + 'type ' => 'nfs', + 'comment' => 'has column missing', + }; + delete $wrongExport->{$requiredCol}; + ok( + ! eval { my $exportID = $configDB->addExport($wrongExport); }, + "inserting an export without '$requiredCol' column should fail" + ); } is( - my @exports = $configDB->fetchExportByFilter, 0, - 'no export yet (array context)' + my @exports = $configDB->fetchExportByFilter, 0, + 'no export yet (array context)' ); is( - my @exportIDs = $configDB->fetchExportIDsOfVendorOS(1), 0, - 'vendor-OS 1 has no export IDs yet' + my @exportIDs = $configDB->fetchExportIDsOfVendorOS(1), 0, + 'vendor-OS 1 has no export IDs yet' ); is( - @exportIDs = $configDB->fetchExportIDsOfVendorOS(2), 0, - 'vendor-OS 2 has no export IDs yet' + @exportIDs = $configDB->fetchExportIDsOfVendorOS(2), 0, + 'vendor-OS 2 has no export IDs yet' ); my $inExport1 = { - 'name' => 'exp-1', - 'type' => 'nfs', - 'vendor_os_id' => 1, - 'comment' => '', + 'name' => 'exp-1', + 'type' => 'nfs', + 'vendor_os_id' => 1, + 'comment' => '', }; is( - my $export1ID = $configDB->addExport($inExport1), 1, - 'first export has ID 1' + my $export1ID = $configDB->addExport($inExport1), 1, + 'first export has ID 1' ); my $inExport2 = { - 'name' => 'exp-2.0', - 'type' => 'sqfs-nbd', - 'vendor_os_id' => 1, - 'comment' => undef, + 'name' => 'exp-2.0', + 'type' => 'sqfs-nbd', + 'vendor_os_id' => 1, + 'comment' => undef, }; my $fullExport = { - 'name' => 'exp-nr-3', - 'type' => 'sqfs-nbd', - 'vendor_os_id' => 2, - 'comment' => 'nuff said', - 'server_ip' => '192.168.212.243', - 'port' => '65432', - 'uri' => 'sqfs-nbd://somehost/somepath?param=val&yes=1', + 'name' => 'exp-nr-3', + 'type' => 'sqfs-nbd', + 'vendor_os_id' => 2, + 'comment' => 'nuff said', + 'server_ip' => '192.168.212.243', + 'port' => '65432', + 'uri' => 'sqfs-nbd://somehost/somepath?param=val&yes=1', }; ok( - my ($export2ID, $export3ID) = $configDB->addExport([ - $inExport2, $fullExport - ]), - 'add two more exports' + my ($export2ID, $export3ID) = $configDB->addExport([ + $inExport2, $fullExport + ]), + 'add two more exports' ); is($export2ID, 2, 'export 2 should have ID=2'); is($export3ID, 3, 'export 3 should have ID=3'); @@ -90,15 +90,15 @@ is($export3->{comment}, 'nuff said', 'export 3 - comment'); is($export3->{server_ip}, '192.168.212.243', 'export 3 - server_ip'); is($export3->{port}, '65432', 'export 3 - port'); is( - $export3->{uri}, - 'sqfs-nbd://somehost/somepath?param=val&yes=1', - 'export 3 - uri' + $export3->{uri}, + 'sqfs-nbd://somehost/somepath?param=val&yes=1', + 'export 3 - uri' ); # fetch export 2 by a filter on id and check all values ok( - my $export2 = $configDB->fetchExportByFilter({ id => 2 }), - 'fetch export 2 by filter on id' + my $export2 = $configDB->fetchExportByFilter({ id => 2 }), + 'fetch export 2 by filter on id' ); is($export2->{id}, 2, 'export 2 - id'); is($export2->{name}, 'exp-2.0', 'export 2 - name'); @@ -108,8 +108,8 @@ is($export2->{comment}, undef, 'export 2 - comment'); # fetch export 1 by filter on name and check all values ok( - my $export1 = $configDB->fetchExportByFilter({ name => 'exp-1' }), - 'fetch export 1 by filter on name' + my $export1 = $configDB->fetchExportByFilter({ name => 'exp-1' }), + 'fetch export 1 by filter on name' ); is($export1->{id}, 1, 'export 1 - id'); is($export1->{name}, 'exp-1', 'export 1 - name'); @@ -121,22 +121,22 @@ is($export1->{server_ip}, undef, 'export 1 - server_ip'); is($export1->{uri}, undef, 'export 1 - uri'); is( - @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(1)), - 2, 'vendor-OS 1 has two export IDs' + @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(1)), + 2, 'vendor-OS 1 has two export IDs' ); is($exportIDs[0], 1, 'first export ID of vendor-OS 1 (1)'); is($exportIDs[1], 2, 'second export ID of vendor-OS 1 (2)'); is( - @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(2)), - 1, 'vendor-OS 2 has one export IDs' + @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(2)), + 1, 'vendor-OS 2 has one export IDs' ); is($exportIDs[0], 3, 'first export ID of vendor-OS 2 (3)'); # fetch exports 3 & 1 by id ok( - my @exports3And1 = $configDB->fetchExportByID([3, 1]), - 'fetch exports 3 & 1 by id' + my @exports3And1 = $configDB->fetchExportByID([3, 1]), + 'fetch exports 3 & 1 by id' ); is(@exports3And1, 2, 'should have got 2 exports'); # now sort by ID and check if we have really got 3 and 1 @@ -146,21 +146,21 @@ is($exports3And1[1]->{id}, 3, 'second id should be 3'); # fetching exports by id without giving any should yield undef is( - $configDB->fetchExportByID(), undef, - 'fetch exports by id without giving any' + $configDB->fetchExportByID(), undef, + 'fetch exports by id without giving any' ); # fetching exports by filter without giving any should yield all of them ok( - @exports = $configDB->fetchExportByFilter(), - 'fetch exports by filter without giving any' + @exports = $configDB->fetchExportByFilter(), + 'fetch exports by filter without giving any' ); is(@exports, 3, 'should have got all three exports'); # fetch exports 1 & 2 by filter on vendor_os_id ok( - my @exports1And2 = $configDB->fetchExportByFilter({ vendor_os_id => '1' }), - 'fetch exports 1 & 2 by filter on vendor_os_id' + my @exports1And2 = $configDB->fetchExportByFilter({ vendor_os_id => '1' }), + 'fetch exports 1 & 2 by filter on vendor_os_id' ); is(@exports1And2, 2, 'should have got 2 exports'); # now sort by ID and check if we have really got 1 and 2 @@ -170,9 +170,9 @@ is($exports1And2[1]->{id}, 2, 'second id should be 2'); # try to fetch with multi-column filter ok( - ($export2, $export3) - = $configDB->fetchExportByFilter({ vendor_os_id => '1', id => 2 }), - 'fetching export with vendor_os_id=1 and id=2 should work' + ($export2, $export3) + = $configDB->fetchExportByFilter({ vendor_os_id => '1', id => 2 }), + 'fetching export with vendor_os_id=1 and id=2 should work' ); is($export2->{name}, 'exp-2.0', 'should have got exp-2.0'); is($export3, undef, 'should not get exp-nr-3'); @@ -180,8 +180,8 @@ is($export3, undef, 'should not get exp-nr-3'); # try to fetch multiple occurrences of the same export, combined with # some unknown IDs ok( - my @exports1And3 = $configDB->fetchExportByID([ 1, 21, 4-1, 1, 0, 1, 1 ]), - 'fetch a complex set of exports by ID' + my @exports1And3 = $configDB->fetchExportByID([ 1, 21, 4-1, 1, 0, 1, 1 ]), + 'fetch a complex set of exports by ID' ); is(@exports1And3, 2, 'should have got 2 exports'); # now sort by ID and check if we have really got 1 and 3 @@ -191,37 +191,37 @@ is($exports1And3[1]->{id}, 3, 'second id should be 3'); # try to fetch a couple of non-existing exports by id is( - $configDB->fetchExportByID(-1), undef, - 'export with id -1 should not exist' + $configDB->fetchExportByID(-1), undef, + 'export with id -1 should not exist' ); is( - $configDB->fetchExportByID(0), undef, - 'export with id 0 should not exist' + $configDB->fetchExportByID(0), undef, + 'export with id 0 should not exist' ); is( - $configDB->fetchExportByID(1 << 31 + 1000), undef, - 'trying to fetch another unknown export' + $configDB->fetchExportByID(1 << 31 + 1000), undef, + 'trying to fetch another unknown export' ); # try to fetch a couple of non-existing exports by filter is( - $configDB->fetchExportByFilter({ id => 0 }), undef, - 'fetching export with id=0 by filter should fail' + $configDB->fetchExportByFilter({ id => 0 }), undef, + 'fetching export with id=0 by filter should fail' ); is( - $configDB->fetchExportByFilter({ name => 'exp-1.x' }), undef, - 'fetching export with name="exp-1.x" should fail' + $configDB->fetchExportByFilter({ name => 'exp-1.x' }), undef, + 'fetching export with name="exp-1.x" should fail' ); is( - $configDB->fetchExportByFilter({ vendor_os_id => '2', id => 1 }), undef, - 'fetching export with vendor_os_id=2 and id=1 should fail' + $configDB->fetchExportByFilter({ vendor_os_id => '2', id => 1 }), undef, + 'fetching export with vendor_os_id=2 and id=1 should fail' ); # rename export 1 and then fetch it by its new name ok($configDB->changeExport(1, { name => q{EXP-'1'} }), 'changing export 1'); ok( - $export1 = $configDB->fetchExportByFilter({ name => q{EXP-'1'} }), - 'fetching renamed export 1' + $export1 = $configDB->fetchExportByFilter({ name => q{EXP-'1'} }), + 'fetching renamed export 1' ); is($export1->{id}, 1, 'really got export number 1'); is($export1->{name}, q{EXP-'1'}, q{really got export named "EXP-'1'"}); @@ -231,8 +231,8 @@ ok($configDB->changeExport(1), 'changing nothing at all in export 1'); # changing a non-existing column should fail ok( - ! eval { $configDB->changeExport(1, { xname => "xx" }) }, - 'changing unknown colum should fail' + ! eval { $configDB->changeExport(1, { xname => "xx" }) }, + 'changing unknown colum should fail' ); ok(! $configDB->changeExport(1, { id => 23 }), 'changing id should fail'); |