diff --git a/internal/collector/textfile/textfile_test_test.go b/internal/collector/textfile/textfile_test_test.go index bc403b1bc7..92d3f33f20 100644 --- a/internal/collector/textfile/textfile_test_test.go +++ b/internal/collector/textfile/textfile_test_test.go @@ -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" ) @@ -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") }