Skip to content

Commit

Permalink
added tests
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 Dec 1, 2024
1 parent 5cab7f3 commit 7ea6162
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/perfdata/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,11 @@ func (c *Collector) Close() {
if c.collectCh != nil {
close(c.collectCh)
}

if c.counterValuesCh != nil {
close(c.counterValuesCh)
}

if c.errorCh != nil {
close(c.errorCh)
}
Expand Down
5 changes: 3 additions & 2 deletions internal/utils/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"log/slog"
"os"
"sync"
"syscall"
"testing"
"time"

Expand All @@ -32,6 +31,7 @@ import (
"github.com/prometheus-community/windows_exporter/pkg/collector"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"
"golang.org/x/sys/windows"
)

func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, collectFunc collector.BuilderWithFlags[C]) {
Expand Down Expand Up @@ -92,6 +92,7 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*
}()

err = c.Build(logger, miSession)

switch {
case err == nil:
case errors.Is(err, mi.MI_RESULT_INVALID_NAMESPACE),
Expand All @@ -108,7 +109,7 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*

switch {
// container collector
case errors.Is(err, syscall.Errno(2151088411)),
case errors.Is(err, windows.Errno(2151088411)),
errors.Is(err, perfdata.ErrPerformanceCounterNotInitialized),
errors.Is(err, perfdata.ErrNoData),
errors.Is(err, mi.MI_RESULT_INVALID_NAMESPACE),
Expand Down

0 comments on commit 7ea6162

Please sign in to comment.