|
6 | 6 | "testing" |
7 | 7 |
|
8 | 8 | "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/hypervisors" |
| 9 | + "github.com/gophercloud/gophercloud/v2/testhelper" |
9 | 10 | th "github.com/gophercloud/gophercloud/v2/testhelper" |
10 | 11 | "github.com/gophercloud/gophercloud/v2/testhelper/client" |
11 | 12 | ) |
@@ -85,8 +86,8 @@ const HypervisorListBodyPre253 = ` |
85 | 86 | ] |
86 | 87 | }` |
87 | 88 |
|
88 | | -// HypervisorListBody represents a raw hypervisor list result with Pike+ release. |
89 | | -const HypervisorListBody = ` |
| 89 | +// HypervisorListBodyPage1 represents page 1 of a raw hypervisor list result with Pike+ release. |
| 90 | +const HypervisorListBodyPage1 = ` |
90 | 91 | { |
91 | 92 | "hypervisors": [ |
92 | 93 | { |
@@ -127,7 +128,20 @@ const HypervisorListBody = ` |
127 | 128 | }, |
128 | 129 | "vcpus": 1, |
129 | 130 | "vcpus_used": 0 |
130 | | - }, |
| 131 | + } |
| 132 | + ], |
| 133 | + "hypervisors_links": [ |
| 134 | + { |
| 135 | + "href": "%s/os-hypervisors/detail?marker=c48f6247-abe4-4a24-824e-ea39e108874f", |
| 136 | + "rel": "next" |
| 137 | + } |
| 138 | + ] |
| 139 | +}` |
| 140 | + |
| 141 | +// HypervisorListBodyPage2 represents page 2 of a raw hypervisor list result with Pike+ release. |
| 142 | +const HypervisorListBodyPage2 = ` |
| 143 | +{ |
| 144 | + "hypervisors": [ |
131 | 145 | { |
132 | 146 | "cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}", |
133 | 147 | "current_workload": 0, |
@@ -157,6 +171,9 @@ const HypervisorListBody = ` |
157 | 171 | ] |
158 | 172 | }` |
159 | 173 |
|
| 174 | +// HypervisorListBodyEmpty represents an empty raw hypervisor list result, marking the end of pagination. |
| 175 | +const HypervisorListBodyEmpty = `{ "hypervisors": [] }` |
| 176 | + |
160 | 177 | // HypervisorListWithParametersBody represents a raw hypervisor list result with Pike+ release. |
161 | 178 | const HypervisorListWithParametersBody = ` |
162 | 179 | { |
@@ -624,8 +641,16 @@ func HandleHypervisorListSuccessfully(t *testing.T) { |
624 | 641 | th.TestMethod(t, r, "GET") |
625 | 642 | th.TestHeader(t, r, "X-Auth-Token", client.TokenID) |
626 | 643 |
|
627 | | - w.Header().Add("Content-Type", "application/json") |
628 | | - fmt.Fprint(w, HypervisorListBody) |
| 644 | + switch r.URL.Query().Get("marker") { |
| 645 | + case "": |
| 646 | + w.Header().Add("Content-Type", "application/json") |
| 647 | + fmt.Fprintf(w, HypervisorListBodyPage1, testhelper.Server.URL) |
| 648 | + case "c48f6247-abe4-4a24-824e-ea39e108874f": |
| 649 | + w.Header().Add("Content-Type", "application/json") |
| 650 | + fmt.Fprint(w, HypervisorListBodyPage2) |
| 651 | + default: |
| 652 | + http.Error(w, "unexpected marker value", http.StatusInternalServerError) |
| 653 | + } |
629 | 654 | }) |
630 | 655 | } |
631 | 656 |
|
|
0 commit comments