Skip to content

Commit

Permalink
textfile: set windows_exporter_collector_success to 0, if errors occurs
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Nov 26, 2024
1 parent b5d8988 commit 2fdbad3
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions internal/collector/textfile/textfile_test_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/prometheus-community/windows_exporter/pkg/collector"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -105,15 +106,8 @@ func TestDuplicateFileName(t *testing.T) {
}()

err := textFileCollector.Collect(metrics)
if err != nil {
t.Errorf("Unexpected error %s", err)
}
require.ErrorContains(t, err, "duplicate filename detected")

if !strings.Contains(got, "file") {
t.Errorf("Unexpected output %q", got)
}

if strings.Contains(got, "sub_file") {
t.Errorf("Unexpected output %q", got)
}
assert.Contains(t, got, "file")
assert.NotContains(t, got, "sub_file")
}

0 comments on commit 2fdbad3

Please sign in to comment.