(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func TestJSONStatsHTTPEndpoint(t *testing.T) { |
| 41 | st := NewJSONStats() |
| 42 | |
| 43 | st.SetConnected(1) |
| 44 | |
| 45 | // Manually set the rate. |
| 46 | st.framesPerSecond.Store(42) |
| 47 | |
| 48 | rec := httptest.NewRecorder() |
| 49 | req := httptest.NewRequest(http.MethodGet, "/", nil) |
| 50 | st.handleRequest(rec, req) |
| 51 | |
| 52 | require.Equal(t, http.StatusOK, rec.Code) |
| 53 | require.Equal(t, "application/json", rec.Header().Get("Content-Type")) |
| 54 | |
| 55 | var snap snapshot |
| 56 | err := json.Unmarshal(rec.Body.Bytes(), &snap) |
| 57 | require.NoError(t, err) |
| 58 | |
| 59 | require.Equal(t, int64(42), snap.FramesPerSecond) |
| 60 | require.Equal(t, int64(1), snap.Connected) |
| 61 | } |
| 62 | |
| 63 | func TestJSONStatsFramesPerSecond(t *testing.T) { |
| 64 | st := NewJSONStats() |
nothing calls this directly
no test coverage detected
searching dependent graphs…