Skip to content

Commit

Permalink
Merge pull request #219 from heroku/vmc-kit-test
Browse files Browse the repository at this point in the history
go-kit: Add CheckCounterExists for testmetrics
  • Loading branch information
Vamsi-Mundra authored Oct 1, 2024
2 parents c8125b8 + e7a6e52 commit e815c61
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions go-kit/metrics/testmetrics/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ func (p *Provider) CheckNoCounter(name string, labelValues ...string) {
}
}

// CheckCounterExists checks that there is registered counter with the name
// provided and value is not 0.
func (p *Provider) CheckCounterExists(name string, labelValues ...string) {
p.t.Helper()

p.Lock()
defer p.Unlock()

k := p.keyFor(name, labelValues...)
counter, ok := p.counters[k]
if !ok {
p.t.Fatalf("a counter named %s was not found", k)
}
if counter.value == 0 {
p.t.Fatalf("counter %s value is 0", k)
}
}

// CheckObservationsMinMax checks that there is a histogram
// with the name and that the values all fall within the min/max range.
func (p *Provider) CheckObservationsMinMax(name string, min, max float64, labelValues ...string) {
Expand Down

0 comments on commit e815c61

Please sign in to comment.