Skip to content

Commit

Permalink
refactor: fix outdated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arcln committed May 17, 2023
1 parent 6bc8b6c commit b030bf4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions internal/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ func TestFolder(t *testing.T) {
Directories: []string{path.Join(filepath.Dir(filename), "../test")},
}, func(metrics []model.MetricFamily) {
foundMetrics := getMetricsForName(metrics, "x509_cert_expired")
assert.Len(t, foundMetrics, 5, "missing x509_cert_expired metric(s)")
assert.Len(t, foundMetrics, 6, "missing x509_cert_expired metric(s)")

foundNbMetrics := getMetricsForName(metrics, "x509_cert_not_before")
assert.Len(t, foundNbMetrics, 5, "missing x509_cert_not_before metric(s)")
assert.Len(t, foundNbMetrics, 6, "missing x509_cert_not_before metric(s)")

foundNaMetrics := getMetricsForName(metrics, "x509_cert_not_after")
assert.Len(t, foundNaMetrics, 5, "missing x509_cert_not_after metric(s)")
assert.Len(t, foundNaMetrics, 6, "missing x509_cert_not_after metric(s)")
})
}

Expand Down Expand Up @@ -353,14 +353,14 @@ func TestErrorMetrics(t *testing.T) {
}

assert.Len(t, errorMetric, 22, "missing x509_read_error metrics")
assert.Equal(t, 19, errors, "missing x509_read_error metrics")
assert.Equal(t, 17, errors, "missing x509_read_error metrics")
} else {
assert.Len(t, errorMetric, 0, "unexpected x509_read_error metrics")
}

errorsMetric := getMetricsForName(metrics, "x509_read_errors")
assert.Len(t, errorsMetric, 1, "missing x509_read_errors metric")
assert.Equal(t, errorsMetric[0].GetGauge().GetValue(), 19., "invalid x509_read_errors value")
assert.Equal(t, errorsMetric[0].GetGauge().GetValue(), 17., "invalid x509_read_errors value")
})
}

Expand Down Expand Up @@ -733,13 +733,13 @@ func TestFileGlobbing(t *testing.T) {
Files: []string{"../test/**/*.pem"},
}, func(metrics []model.MetricFamily) {
foundMetrics := getMetricsForName(metrics, "x509_cert_expired")
assert.Len(t, foundMetrics, 6)
assert.Len(t, foundMetrics, 8)
foundNbMetrics := getMetricsForName(metrics, "x509_cert_not_before")
assert.Len(t, foundNbMetrics, 6)
assert.Len(t, foundNbMetrics, 8)
foundNaMetrics := getMetricsForName(metrics, "x509_cert_not_after")
assert.Len(t, foundNaMetrics, 6)
assert.Len(t, foundNaMetrics, 8)
errMetric := getMetricsForName(metrics, "x509_read_errors")
assert.Equal(t, 4., errMetric[0].GetGauge().GetValue())
assert.Equal(t, 2., errMetric[0].GetGauge().GetValue())
})

// invalid pattern
Expand Down Expand Up @@ -810,13 +810,13 @@ func TestDirectoryGlobbing(t *testing.T) {
Directories: []string{"../tes*"},
}, func(metrics []model.MetricFamily) {
foundMetrics := getMetricsForName(metrics, "x509_cert_expired")
assert.Len(t, foundMetrics, 4)
assert.Len(t, foundMetrics, 6)
foundNbMetrics := getMetricsForName(metrics, "x509_cert_not_before")
assert.Len(t, foundNbMetrics, 4)
assert.Len(t, foundNbMetrics, 6)
foundNaMetrics := getMetricsForName(metrics, "x509_cert_not_after")
assert.Len(t, foundNaMetrics, 4)
assert.Len(t, foundNaMetrics, 6)
errMetric := getMetricsForName(metrics, "x509_read_errors")
assert.Equal(t, 19., errMetric[0].GetGauge().GetValue())
assert.Equal(t, 17., errMetric[0].GetGauge().GetValue())
})

// double star match
Expand Down

0 comments on commit b030bf4

Please sign in to comment.