35_remove2.t 1.23 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#!perl

use strict;
use warnings;
use Test::More;

use lib 't/lib';
use Test::Ravada;

# init ravada for testing
Francesc Guasch's avatar
Francesc Guasch committed
11
init();
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
my $USER = create_user("foo","bar", 1);

##############################################################################

sub test_remove_domain {
    my $vm = shift;

    my $domain = create_domain($vm->type);
    $domain->shutdown( user => user_admin )  if $domain->is_active();
    
    $domain->domain->undefine();

    my $removed = $domain->is_removed;

    ok($removed, "Domain deleted: $removed");
    
    eval{ $domain->remove(user_admin) };
    
    is($@,"");

    my $list = rvd_front->list_domains();
    is(scalar @$list , 0);

}


##############################################################################

clean();

use_ok('Ravada');

for my $vm_name ( q'KVM' ) {

    my $vm;
    eval { $vm = rvd_back->search_vm($vm_name) };

    SKIP: {
        my $msg = "SKIPPED test: No $vm_name VM found ";
        if ($vm && $vm_name =~ /kvm/i && $>) {
            $msg = "SKIPPED: Test must run as root";
            $vm = undef;
        }

        diag($msg)      if !$vm;
Francesc Guasch's avatar
Francesc Guasch committed
57
        skip $msg,10    if !$vm;
58
59
60
61
62
63
64
65
66
67

        diag("Testing remove on $vm_name");

		test_remove_domain($vm);        

    }
}

clean();

Francesc Guasch's avatar
Francesc Guasch committed
68
done_testing();