chore: added tests (#1800)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2024-12-01 21:50:49 +01:00
committed by GitHub
parent 0ad8e01e0e
commit 109c34f572
34 changed files with 196 additions and 11 deletions

View File

@@ -47,7 +47,10 @@ var ConfigDefaults = Config{
scrapeInterval: 6 * time.Hour,
}
var ErrNoUpdates = errors.New("pending gather update metrics")
var (
ErrNoUpdates = errors.New("pending gather update metrics")
ErrUpdateServiceDisabled = errors.New("windows updates service is disabled")
)
type Collector struct {
config Config
@@ -234,7 +237,7 @@ func (c *Collector) scheduleUpdateStatus(ctx context.Context, logger *slog.Logge
}(hc)
if err != nil {
initErrCh <- fmt.Errorf("windows updates service is disabled: %w", err)
initErrCh <- ErrUpdateServiceDisabled
return
}

View File

@@ -23,5 +23,9 @@ import (
)
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, "printer", update.NewWithFlags)
testutils.FuncBenchmarkCollector(b, update.Name, update.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, update.New, nil)
}