Skip to content

Commit

Permalink
Create a Between MetricValueExpectation (#65)
Browse files Browse the repository at this point in the history
Signed-off-by: Douglas Camata <[email protected]>
  • Loading branch information
douglascamata authored Apr 13, 2023
1 parent 29a5a4d commit ebc233c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions monitoring/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@ func Less(value float64) MetricValueExpectation {
}
}

// Between is a MetricValueExpectation function for WaitSumMetrics that returns true if given single sum is between
// the lower and upper bounds (non-inclusive, as in `lower < x < upper`).
func Between(lower, upper float64) MetricValueExpectation {
return func(sums ...float64) bool {
if len(sums) != 1 {
panic("between: expected one value")
}
return sums[0] > lower && sums[0] < upper
}
}

// EqualsAmongTwo is an isExpected function for WaitSumMetrics that returns true if first sum is equal to the second.
// NOTE: Be careful on scrapes in between of process that changes two metrics. Those are
// usually not atomic.
Expand Down

0 comments on commit ebc233c

Please sign in to comment.