forked from UPC/ravada
-
Notifications
You must be signed in to change notification settings - Fork 0
/
05_open.t
63 lines (45 loc) · 1.34 KB
/
05_open.t
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use warnings;
use strict;
use Carp qw(confess);
use Data::Dumper;
use IPC::Run3;
use Test::More;
use Test::SQL::Data;
use lib 't/lib';
use Test::Ravada;
my $test = Test::SQL::Data->new(config => 't/etc/sql.conf');
use_ok('Ravada');
init($test->connector);
clean();
#############################################################
sub test_create_domain {
my $vm_type = shift;
my $domain = create_domain($vm_type);
my $domain_open = Ravada::Domain->open($domain->id);
is(ref($domain_open),"Ravada::Domain::$vm_type"
,"Expecting domain in $vm_type");
my $id_domain = $domain->id;
like($id_domain,qr/^\d+/);
$domain->remove(user_admin);
if (defined $id_domain) {
my $domain_gone;
eval { $domain_gone = Ravada::Domain->open($id_domain)};
is($domain_gone,undef,"Expecting no domain ".$id_domain);
}
}
my $id = 1;
for my $vm_type( @{rvd_front->list_vm_types}) {
diag($vm_type);
my $exp_class = "Ravada::VM::$vm_type";
my $sth = $test->connector->dbh->prepare(
"INSERT INTO vms (id, name, vm_type, hostname) "
." VALUES(?,?,?,?)"
);
$sth->execute($id, $vm_type, $vm_type, 'localhost');
$sth->finish;
my $vm = Ravada::VM->open($id);
is(ref($vm),$exp_class);
test_create_domain($vm_type) if rvd_back->search_vm($vm_type);
$id++;
}
done_testing();