summaryrefslogtreecommitdiffstats
path: root/config-db/t/15-global_info.t
blob: 8f2f8cf145ef46f279ace6d2367d81005531f711 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use Test::More qw(no_plan);

use strict;
use warnings;

use lib '/opt/openslx/lib';

# basic init
use OpenSLX::ConfigDB;

my $configDB = OpenSLX::ConfigDB->new;
$configDB->connect();

# fetch global-info 'next-nbd-server-port'
ok(
    my $globalInfo = $configDB->fetchGlobalInfo('next-nbd-server-port'), 
    'fetch global-info'
);
is($globalInfo, '5000', 'global-info - value');

# try to fetch a couple of non-existing global-infos
is(
    $configDB->fetchGlobalInfo(-1), undef, 
    'global-info with id -1 should not exist'
);
is($configDB->fetchGlobalInfo('xxx'), undef, 
    'global-info with id xxx should not exist');

# change value of global-info and then fetch and check the new value
ok($configDB->changeGlobalInfo('next-nbd-server-port', '5050'), 'changing global-info');
is(
    $configDB->fetchGlobalInfo('next-nbd-server-port'), '5050',
    'fetching changed global-info'
);

# changing a non-existing global-info should fail
ok(
    ! eval { $configDB->changeGlobalInfo('xxx', 'new-value') }, 
    'changing unknown global-info should fail'
);

$configDB->disconnect();