(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestHttpServer_handleClusterList(t *testing.T) { |
| 27 | coordinator := fixtureConfiguredCoordinator() |
| 28 | |
| 29 | // Respond to the expected storage request |
| 30 | go func() { |
| 31 | request := <-coordinator.App.StorageChannel |
| 32 | assert.Equalf(t, protocol.StorageFetchClusters, request.RequestType, "Expected request of type StorageFetchClusters, not %v", request.RequestType) |
| 33 | request.Reply <- []string{"testcluster"} |
| 34 | close(request.Reply) |
| 35 | }() |
| 36 | |
| 37 | // Set up a request |
| 38 | req, err := http.NewRequest("GET", "/v3/kafka", http.NoBody) |
| 39 | assert.NoError(t, err, "Expected request setup to return no error") |
| 40 | |
| 41 | // Call the handler via httprouter |
| 42 | rr := httptest.NewRecorder() |
| 43 | coordinator.router.ServeHTTP(rr, req) |
| 44 | |
| 45 | assert.Equalf(t, http.StatusOK, rr.Code, "Expected response code to be 200, not %v", rr.Code) |
| 46 | |
| 47 | // Parse response body |
| 48 | decoder := json.NewDecoder(rr.Body) |
| 49 | var resp httpResponseClusterList |
| 50 | err = decoder.Decode(&resp) |
| 51 | assert.NoError(t, err, "Expected body decode to return no error") |
| 52 | assert.False(t, resp.Error, "Expected response Error to be false") |
| 53 | assert.Equalf(t, []string{"testcluster"}, resp.Clusters, "Expected Clusters list to contain just testcluster, not %v", resp.Clusters) |
| 54 | } |
| 55 | |
| 56 | func TestHttpServer_handleClusterDetail(t *testing.T) { |
| 57 | coordinator := fixtureConfiguredCoordinator() |
nothing calls this directly
no test coverage detected