MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestCompareScalar

Function TestCompareScalar

tools/querytee/response_comparator_test.go:188–223  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

186}
187
188func TestCompareScalar(t *testing.T) {
189 for _, tc := range []struct {
190 name string
191 expected json.RawMessage
192 actual json.RawMessage
193 err error
194 }{
195 {
196 name: "difference in timestamp",
197 expected: json.RawMessage(`[1,"1"]`),
198 actual: json.RawMessage(`[2,"1"]`),
199 err: errors.New("expected timestamp 1 but got 2"),
200 },
201 {
202 name: "difference in value",
203 expected: json.RawMessage(`[1,"1"]`),
204 actual: json.RawMessage(`[1,"2"]`),
205 err: errors.New("expected value 1 for timestamp 1 but got 2"),
206 },
207 {
208 name: "correct values",
209 expected: json.RawMessage(`[1,"1"]`),
210 actual: json.RawMessage(`[1,"1"]`),
211 },
212 } {
213 t.Run(tc.name, func(t *testing.T) {
214 err := compareScalar(tc.expected, tc.actual, 0)
215 if tc.err == nil {
216 require.NoError(t, err)
217 return
218 }
219 require.Error(t, err)
220 require.Equal(t, tc.err.Error(), err.Error())
221 })
222 }
223}
224
225func TestCompareSamplesResponse(t *testing.T) {
226 for _, tc := range []struct {

Callers

nothing calls this directly

Calls 4

compareScalarFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected