MCPcopy Index your code
hub / github.com/cortexproject/cortex / compareScalar

Function compareScalar

tools/querytee/response_comparator.go:176–195  ·  view source on GitHub ↗
(expectedRaw, actualRaw json.RawMessage, tolerance float64)

Source from the content-addressed store, hash-verified

174}
175
176func compareScalar(expectedRaw, actualRaw json.RawMessage, tolerance float64) error {
177 var expected, actual model.Scalar
178 err := json.Unmarshal(expectedRaw, &expected)
179 if err != nil {
180 return err
181 }
182
183 err = json.Unmarshal(actualRaw, &actual)
184 if err != nil {
185 return err
186 }
187
188 return compareSamplePair(model.SamplePair{
189 Timestamp: expected.Timestamp,
190 Value: expected.Value,
191 }, model.SamplePair{
192 Timestamp: actual.Timestamp,
193 Value: actual.Value,
194 }, tolerance)
195}
196
197func compareSamplePair(expected, actual model.SamplePair, tolerance float64) error {
198 if expected.Timestamp != actual.Timestamp {

Callers 1

TestCompareScalarFunction · 0.85

Calls 2

compareSamplePairFunction · 0.85
UnmarshalMethod · 0.45

Tested by 1

TestCompareScalarFunction · 0.68