MCPcopy Index your code
hub / github.com/apache/cloudstack-go / TestNicService

Function TestNicService

test/NicService_test.go:28–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestNicService(t *testing.T) {
29 service := "NicService"
30 response, err := readData(service)
31 if err != nil {
32 t.Skipf("Skipping test as %v", err)
33 }
34 server := CreateTestServer(t, response)
35 client := cloudstack.NewClient(server.URL, "APIKEY", "SECRETKEY", true)
36 defer server.Close()
37
38 testaddIpToNic := func(t *testing.T) {
39 if _, ok := response["addIpToNic"]; !ok {
40 t.Skipf("Skipping as no json response is provided in testdata")
41 }
42 p := client.Nic.NewAddIpToNicParams("nicid")
43 r, err := client.Nic.AddIpToNic(p)
44 if err != nil {
45 t.Errorf(err.Error())
46 }
47 if r.Id == "" {
48 t.Errorf("Failed to parse response. ID not found")
49 }
50 }
51 t.Run("AddIpToNic", testaddIpToNic)
52
53 testlistNics := func(t *testing.T) {
54 if _, ok := response["listNics"]; !ok {
55 t.Skipf("Skipping as no json response is provided in testdata")
56 }
57 p := client.Nic.NewListNicsParams("virtualmachineid")
58 _, err := client.Nic.ListNics(p)
59 if err != nil {
60 t.Errorf(err.Error())
61 }
62 }
63 t.Run("ListNics", testlistNics)
64
65 testremoveIpFromNic := func(t *testing.T) {
66 if _, ok := response["removeIpFromNic"]; !ok {
67 t.Skipf("Skipping as no json response is provided in testdata")
68 }
69 p := client.Nic.NewRemoveIpFromNicParams("id")
70 _, err := client.Nic.RemoveIpFromNic(p)
71 if err != nil {
72 t.Errorf(err.Error())
73 }
74 }
75 t.Run("RemoveIpFromNic", testremoveIpFromNic)
76
77 testupdateVmNicIp := func(t *testing.T) {
78 if _, ok := response["updateVmNicIp"]; !ok {
79 t.Skipf("Skipping as no json response is provided in testdata")
80 }
81 p := client.Nic.NewUpdateVmNicIpParams("nicid")
82 r, err := client.Nic.UpdateVmNicIp(p)
83 if err != nil {
84 t.Errorf(err.Error())
85 }

Callers

nothing calls this directly

Calls 12

NewClientFunction · 0.92
readDataFunction · 0.85
CreateTestServerFunction · 0.85
NewAddIpToNicParamsMethod · 0.65
AddIpToNicMethod · 0.65
NewListNicsParamsMethod · 0.65
ListNicsMethod · 0.65
RemoveIpFromNicMethod · 0.65
UpdateVmNicIpMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected