(t *testing.T)
| 201 | } |
| 202 | |
| 203 | func TestStatusAPI(t *testing.T) { |
| 204 | dms := storage.NewDiskMetricStore("", 100*time.Millisecond, nil, logger) |
| 205 | testAPI := New(logger, dms, testFlags, testBuildInfo) |
| 206 | |
| 207 | req, err := http.NewRequest("GET", "http://example.org/", &bytes.Buffer{}) |
| 208 | if err != nil { |
| 209 | t.Fatal(err) |
| 210 | } |
| 211 | |
| 212 | w := httptest.NewRecorder() |
| 213 | |
| 214 | testResponse := response{} |
| 215 | testAPI.status(w, req) |
| 216 | if err := json.Unmarshal(w.Body.Bytes(), &testResponse); err != nil { |
| 217 | t.Fatalf("unexpected error unmarshaling response: %v", err) |
| 218 | } |
| 219 | jsonData := testResponse.Data.(map[string]any) |
| 220 | responseFlagData := jsonData["flags"].(map[string]any) |
| 221 | responseBuildInfo := jsonData["build_information"].(map[string]any) |
| 222 | |
| 223 | if expected, got := http.StatusOK, w.Code; expected != got { |
| 224 | t.Errorf("Wanted status code %v, got %v.", expected, got) |
| 225 | } |
| 226 | |
| 227 | if !reflect.DeepEqual(responseFlagData, convertMap(testFlags)) { |
| 228 | t.Errorf("Wanted following flags %q, got %q.", testFlags, responseFlagData) |
| 229 | } |
| 230 | |
| 231 | if !reflect.DeepEqual(responseBuildInfo, convertMap(testBuildInfo)) { |
| 232 | t.Errorf("Wanted following build info %q, got %q.", testBuildInfo, responseBuildInfo) |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | func TestMetricsAPI(t *testing.T) { |
| 237 | dms := storage.NewDiskMetricStore("", 100*time.Millisecond, nil, logger) |
nothing calls this directly
no test coverage detected
searching dependent graphs…