Add HasPoint method to testutil.Accumulator

This commit is contained in:
Daniel Nelson
2017-10-09 15:02:57 -07:00
parent 0f452ad0df
commit 761544f56d
2 changed files with 69 additions and 48 deletions

View File

@@ -297,6 +297,31 @@ func (a *Accumulator) AssertContainsFields(
assert.Fail(t, msg)
}
func (a *Accumulator) HasPoint(
measurement string,
tags map[string]string,
fieldKey string,
fieldValue interface{},
) bool {
a.Lock()
defer a.Unlock()
for _, p := range a.Metrics {
if p.Measurement != measurement {
continue
}
if !reflect.DeepEqual(tags, p.Tags) {
continue
}
v, ok := p.Fields[fieldKey]
if ok && reflect.DeepEqual(v, fieldValue) {
return true
}
}
return false
}
func (a *Accumulator) AssertDoesNotContainMeasurement(t *testing.T, measurement string) {
a.Lock()
defer a.Unlock()