-
Notifications
You must be signed in to change notification settings - Fork 20
/
nic_create_test.go
89 lines (81 loc) · 1.64 KB
/
nic_create_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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package ovirtclient_test
import (
"fmt"
"testing"
ovirtclient "github.com/ovirt/go-ovirt-client/v3"
)
func TestVMNICCreation(t *testing.T) {
t.Parallel()
helper := getHelper(t)
vm := assertCanCreateVM(
t,
helper,
fmt.Sprintf("nic_test_%s", helper.GenerateRandomID(5)),
ovirtclient.CreateVMParams(),
)
assertNICCount(t, vm, 0)
nic := assertCanCreateNIC(
t,
helper,
vm,
fmt.Sprintf("test-%s", helper.GenerateRandomID(5)),
ovirtclient.CreateNICParams())
assertNICCount(t, vm, 1)
assertCanRemoveNIC(t, nic)
assertNICCount(t, vm, 0)
}
func TestDuplicateVMNICCreation(t *testing.T) {
t.Parallel()
helper := getHelper(t)
nicName := "test_duplicate_name"
vm := assertCanCreateVM(
t,
helper,
fmt.Sprintf("nic_test_%s", helper.GenerateRandomID(5)),
ovirtclient.CreateVMParams(),
)
assertNICCount(t, vm, 0)
nic1 := assertCanCreateNIC(
t,
helper,
vm,
nicName,
ovirtclient.CreateNICParams())
assertNICCount(t, vm, 1)
assertCannotCreateNIC(
t,
helper,
vm,
nicName,
ovirtclient.CreateNICParams())
assertNICCount(t, vm, 1)
assertCanRemoveNIC(t, nic1)
assertNICCount(t, vm, 0)
}
func TestVMNICWithMacCreation(t *testing.T) {
t.Parallel()
helper := getHelper(t)
mac := "a1:b2:c3:d4:e5:f6"
invalidMac := "invalid mac address"
vm := assertCanCreateVM(
t,
helper,
fmt.Sprintf("nic_test_%s", helper.GenerateRandomID(5)),
ovirtclient.CreateVMParams(),
)
assertNICCount(t, vm, 0)
nic := assertCanCreateNICMac(
t,
helper,
vm,
mac)
assertNICCount(t, vm, 1)
assertCantCreateNICMac(
t,
helper,
vm,
invalidMac)
assertNICCount(t, vm, 1)
assertCanRemoveNIC(t, nic)
assertNICCount(t, vm, 0)
}