chore: update linter.
This commit is contained in:
parent
da1c9f48b7
commit
f54136b602
12 changed files with 63 additions and 8 deletions
|
@ -300,6 +300,8 @@ func findPilotMetric(name string, metrics []PilotMetric) *PilotMetric {
|
|||
}
|
||||
|
||||
func buildPilotCounterAssert(t *testing.T, metricName string, expectedValue float64) func(metric *PilotMetric) {
|
||||
t.Helper()
|
||||
|
||||
return func(metric *PilotMetric) {
|
||||
for _, value := range metric.Observations {
|
||||
if cv := value.(float64); cv != expectedValue {
|
||||
|
@ -311,6 +313,8 @@ func buildPilotCounterAssert(t *testing.T, metricName string, expectedValue floa
|
|||
}
|
||||
|
||||
func buildPilotGreaterThanCounterAssert(t *testing.T, metricName string, expectedMinValue float64) func(metric *PilotMetric) {
|
||||
t.Helper()
|
||||
|
||||
return func(metric *PilotMetric) {
|
||||
for _, value := range metric.Observations {
|
||||
if cv := value.(float64); cv < expectedMinValue {
|
||||
|
@ -322,6 +326,8 @@ func buildPilotGreaterThanCounterAssert(t *testing.T, metricName string, expecte
|
|||
}
|
||||
|
||||
func buildPilotHistogramAssert(t *testing.T, metricName string, expectedSampleCount float64) func(metric *PilotMetric) {
|
||||
t.Helper()
|
||||
|
||||
return func(metric *PilotMetric) {
|
||||
for _, value := range metric.Observations {
|
||||
if pho := value.(*pilotHistogramObservation); pho.Count != expectedSampleCount {
|
||||
|
@ -333,6 +339,8 @@ func buildPilotHistogramAssert(t *testing.T, metricName string, expectedSampleCo
|
|||
}
|
||||
|
||||
func buildPilotGaugeAssert(t *testing.T, metricName string, expectedValue float64) func(metric *PilotMetric) {
|
||||
t.Helper()
|
||||
|
||||
return func(metric *PilotMetric) {
|
||||
for _, value := range metric.Observations {
|
||||
if gv := value.(float64); gv != expectedValue {
|
||||
|
@ -344,6 +352,8 @@ func buildPilotGaugeAssert(t *testing.T, metricName string, expectedValue float6
|
|||
}
|
||||
|
||||
func buildPilotTimestampAssert(t *testing.T, metricName string) func(metric *PilotMetric) {
|
||||
t.Helper()
|
||||
|
||||
return func(metric *PilotMetric) {
|
||||
for _, value := range metric.Observations {
|
||||
if ts := time.Unix(int64(value.(float64)), 0); time.Since(ts) > time.Minute {
|
||||
|
|
|
@ -472,6 +472,8 @@ func assertCounterValue(t *testing.T, want float64, family *dto.MetricFamily, la
|
|||
}
|
||||
|
||||
func buildCounterAssert(t *testing.T, metricName string, expectedValue int) func(family *dto.MetricFamily) {
|
||||
t.Helper()
|
||||
|
||||
return func(family *dto.MetricFamily) {
|
||||
if cv := int(family.Metric[0].Counter.GetValue()); cv != expectedValue {
|
||||
t.Errorf("metric %s has value %d, want %d", metricName, cv, expectedValue)
|
||||
|
@ -480,6 +482,8 @@ func buildCounterAssert(t *testing.T, metricName string, expectedValue int) func
|
|||
}
|
||||
|
||||
func buildGreaterThanCounterAssert(t *testing.T, metricName string, expectedMinValue int) func(family *dto.MetricFamily) {
|
||||
t.Helper()
|
||||
|
||||
return func(family *dto.MetricFamily) {
|
||||
if cv := int(family.Metric[0].Counter.GetValue()); cv < expectedMinValue {
|
||||
t.Errorf("metric %s has value %d, want at least %d", metricName, cv, expectedMinValue)
|
||||
|
@ -488,6 +492,8 @@ func buildGreaterThanCounterAssert(t *testing.T, metricName string, expectedMinV
|
|||
}
|
||||
|
||||
func buildHistogramAssert(t *testing.T, metricName string, expectedSampleCount int) func(family *dto.MetricFamily) {
|
||||
t.Helper()
|
||||
|
||||
return func(family *dto.MetricFamily) {
|
||||
if sc := int(family.Metric[0].Histogram.GetSampleCount()); sc != expectedSampleCount {
|
||||
t.Errorf("metric %s has sample count value %d, want %d", metricName, sc, expectedSampleCount)
|
||||
|
@ -496,6 +502,8 @@ func buildHistogramAssert(t *testing.T, metricName string, expectedSampleCount i
|
|||
}
|
||||
|
||||
func buildGaugeAssert(t *testing.T, metricName string, expectedValue int) func(family *dto.MetricFamily) {
|
||||
t.Helper()
|
||||
|
||||
return func(family *dto.MetricFamily) {
|
||||
if gv := int(family.Metric[0].Gauge.GetValue()); gv != expectedValue {
|
||||
t.Errorf("metric %s has value %d, want %d", metricName, gv, expectedValue)
|
||||
|
@ -504,6 +512,8 @@ func buildGaugeAssert(t *testing.T, metricName string, expectedValue int) func(f
|
|||
}
|
||||
|
||||
func buildTimestampAssert(t *testing.T, metricName string) func(family *dto.MetricFamily) {
|
||||
t.Helper()
|
||||
|
||||
return func(family *dto.MetricFamily) {
|
||||
if ts := time.Unix(int64(family.Metric[0].Gauge.GetValue()), 0); time.Since(ts) > time.Minute {
|
||||
t.Errorf("metric %s has wrong timestamp %v", metricName, ts)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue