-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathvm_graphics_console_test.go
36 lines (33 loc) · 1.05 KB
/
vm_graphics_console_test.go
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
package ovirtclient_test
import (
"testing"
ovirtclient "github.com/ovirt/go-ovirt-client/v3"
)
func TestListAndRemoveGraphicsConsoles(t *testing.T) {
helper := getHelper(t)
vm := assertCanCreateVM(
t,
helper,
helper.GenerateTestResourceName(t),
ovirtclient.NewCreateVMParams().MustWithVMType(ovirtclient.VMTypeDesktop),
)
graphicsConsoles, err := vm.ListGraphicsConsoles()
if err != nil {
t.Fatalf("Failed to list graphics consoles on VM %s (%v)", vm.ID(), err)
}
if len(graphicsConsoles) == 0 {
t.Fatalf("No graphics consoles found on desktop VM.")
}
for _, graphicsConsole := range graphicsConsoles {
if err := graphicsConsole.Remove(); err != nil {
t.Fatalf("failed to remove graphics console %s from VM %s (%v)", graphicsConsole.ID(), vm.ID(), err)
}
}
newGraphicsConsoles, err := helper.GetClient().ListVMGraphicsConsoles(vm.ID())
if err != nil {
t.Fatalf("Failed to list graphics consoles for VM %s (%v)", vm.ID(), err)
}
if len(newGraphicsConsoles) != 0 {
t.Fatalf("Still found graphics consoles after removing them.")
}
}