(t *testing.T)
| 220 | } |
| 221 | |
| 222 | func Test_InvalidCodec(t *testing.T) { |
| 223 | engine := engine2.New( |
| 224 | promql.EngineOpts{ |
| 225 | MaxSamples: 100, |
| 226 | Timeout: time.Second * 2, |
| 227 | }, |
| 228 | engine2.ThanosEngineConfig{Enabled: false}, |
| 229 | prometheus.NewRegistry()) |
| 230 | |
| 231 | mockQueryable := &mockSampleAndChunkQueryable{ |
| 232 | queryableFn: func(_, _ int64) (storage.Querier, error) { |
| 233 | return mockQuerier{ |
| 234 | matrix: model.Matrix{ |
| 235 | { |
| 236 | Metric: model.Metric{"__name__": "test", "foo": "bar"}, |
| 237 | Values: []model.SamplePair{ |
| 238 | {Timestamp: 1536673665000, Value: 0}, |
| 239 | {Timestamp: 1536673670000, Value: 1}, |
| 240 | }, |
| 241 | }, |
| 242 | }, |
| 243 | }, nil |
| 244 | }, |
| 245 | } |
| 246 | |
| 247 | queryAPI := NewQueryAPI(engine, mockQueryable, querier.StatsRenderer, log.NewNopLogger(), []v1.Codec{&mockCodec{}}, regexp.MustCompile(".*")) |
| 248 | router := mux.NewRouter() |
| 249 | router.Path("/api/v1/query").Methods("POST").Handler(queryAPI.Wrap(queryAPI.InstantQueryHandler)) |
| 250 | |
| 251 | req := httptest.NewRequest(http.MethodPost, "/api/v1/query?query=test", nil) |
| 252 | ctx := context.Background() |
| 253 | _, ctx = stats.ContextWithEmptyStats(ctx) |
| 254 | req = req.WithContext(user.InjectOrgID(ctx, "user1")) |
| 255 | |
| 256 | rec := httptest.NewRecorder() |
| 257 | router.ServeHTTP(rec, req) |
| 258 | require.Equal(t, http.StatusNotAcceptable, rec.Code) |
| 259 | } |
| 260 | |
| 261 | func Test_CustomAPI_StatsRenderer(t *testing.T) { |
| 262 | engine := engine2.New( |
nothing calls this directly
no test coverage detected