-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathvnicprofile_test.go
57 lines (51 loc) · 1.44 KB
/
vnicprofile_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
package ovirtclient_test
import (
"fmt"
"testing"
ovirtclient "github.com/ovirt/go-ovirt-client/v3"
)
func TestVNICProfile(t *testing.T) {
t.Parallel()
helper := getHelper(t)
client := helper.GetClient()
networks, err := client.ListNetworks()
if err != nil {
t.Fatalf("failed to list networks (%v)", err)
}
if len(networks) == 0 {
t.Fatalf("no networks found")
}
vnicProfile, err := client.CreateVNICProfile(
fmt.Sprintf("client_test_%s", helper.GenerateRandomID(5)),
networks[0].ID(),
ovirtclient.CreateVNICProfileParams(),
)
if err != nil {
t.Fatalf("failed to create VNIC profile (%v)", err)
}
if err := vnicProfile.Remove(); err != nil {
t.Fatalf("failed to remove VNIC profile (%v)", err)
}
}
func assertCanCreateVNICProfile(t *testing.T, helper ovirtclient.TestHelper) ovirtclient.VNICProfile {
client := helper.GetClient()
vnicProfile, err := client.GetVNICProfile(helper.GetVNICProfileID())
if err != nil {
t.Fatalf("failed to fetch test VNIC profile (%v)", err)
}
newVNICProfile, err := client.CreateVNICProfile(
fmt.Sprintf("client_test_%s", helper.GenerateRandomID(5)),
vnicProfile.NetworkID(),
ovirtclient.CreateVNICProfileParams(),
)
if err != nil {
t.Fatalf("failed to create test VNIC profile (%v)", err)
}
t.Cleanup(
func() {
if err := newVNICProfile.Remove(); err != nil {
t.Fatalf("failed to clean up test VNIC profile ID %s (%v)", newVNICProfile.ID(), err)
}
})
return newVNICProfile
}