(t *testing.T)
| 32 | } |
| 33 | |
| 34 | func newStorageTestServer(t *testing.T) *httptest.Server { |
| 35 | t.Helper() |
| 36 | |
| 37 | return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 38 | w.Header().Set("Content-Type", "application/json") |
| 39 | |
| 40 | switch { |
| 41 | case r.URL.Path == "/api2/json/access/ticket": |
| 42 | _, _ = w.Write([]byte(authResponse)) |
| 43 | |
| 44 | case strings.HasSuffix(r.URL.Path, "/storage") && strings.Contains(r.URL.Path, "/nodes/"): |
| 45 | _, _ = w.Write([]byte(storageListResponse())) |
| 46 | |
| 47 | case strings.Contains(r.URL.Path, "/storage/") && strings.HasSuffix(r.URL.Path, "/content"): |
| 48 | _, _ = w.Write([]byte(storageContentResponse())) |
| 49 | |
| 50 | case r.URL.Path == "/api2/json/cluster/resources": |
| 51 | // Minimal cluster resources so getNodes works. |
| 52 | _, _ = w.Write([]byte(`{"data":[{"type":"node","node":"pve01","status":"online","id":"node/pve01"}]}`)) |
| 53 | |
| 54 | case r.URL.Path == "/api2/json/cluster/status": |
| 55 | _, _ = w.Write([]byte(`{"data":[{"type":"cluster","name":"pve","nodes":1}]}`)) |
| 56 | |
| 57 | default: |
| 58 | http.NotFound(w, r) |
| 59 | } |
| 60 | })) |
| 61 | } |
| 62 | |
| 63 | func TestStorageListReturnsRows(t *testing.T) { |
| 64 | server := newStorageTestServer(t) |
no test coverage detected