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

Function TestVMGroupService

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

Source from the content-addressed store, hash-verified

26)
27
28func TestVMGroupService(t *testing.T) {
29 service := "VMGroupService"
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 testcreateInstanceGroup := func(t *testing.T) {
39 if _, ok := response["createInstanceGroup"]; !ok {
40 t.Skipf("Skipping as no json response is provided in testdata")
41 }
42 p := client.VMGroup.NewCreateInstanceGroupParams("name")
43 r, err := client.VMGroup.CreateInstanceGroup(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("CreateInstanceGroup", testcreateInstanceGroup)
52
53 testdeleteInstanceGroup := func(t *testing.T) {
54 if _, ok := response["deleteInstanceGroup"]; !ok {
55 t.Skipf("Skipping as no json response is provided in testdata")
56 }
57 p := client.VMGroup.NewDeleteInstanceGroupParams("id")
58 _, err := client.VMGroup.DeleteInstanceGroup(p)
59 if err != nil {
60 t.Errorf(err.Error())
61 }
62 }
63 t.Run("DeleteInstanceGroup", testdeleteInstanceGroup)
64
65 testlistInstanceGroups := func(t *testing.T) {
66 if _, ok := response["listInstanceGroups"]; !ok {
67 t.Skipf("Skipping as no json response is provided in testdata")
68 }
69 p := client.VMGroup.NewListInstanceGroupsParams()
70 _, err := client.VMGroup.ListInstanceGroups(p)
71 if err != nil {
72 t.Errorf(err.Error())
73 }
74 }
75 t.Run("ListInstanceGroups", testlistInstanceGroups)
76
77 testupdateInstanceGroup := func(t *testing.T) {
78 if _, ok := response["updateInstanceGroup"]; !ok {
79 t.Skipf("Skipping as no json response is provided in testdata")
80 }
81 p := client.VMGroup.NewUpdateInstanceGroupParams("id")
82 r, err := client.VMGroup.UpdateInstanceGroup(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
CreateInstanceGroupMethod · 0.65
DeleteInstanceGroupMethod · 0.65
ListInstanceGroupsMethod · 0.65
UpdateInstanceGroupMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected