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

@@ -272,6 +272,10 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
// Collect sends the metric values for each metric
// to the provided prometheus Metric channel.
func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
if len(c.mssqlInstances) == 0 {
return fmt.Errorf("no SQL instances found: %w", perfdata.ErrNoData)
}
errCh := make(chan error, len(c.collectorFns))
errs := make([]error, 0, len(c.collectorFns))

View File

@@ -25,3 +25,7 @@ import (
func BenchmarkCollector(b *testing.B) {
testutils.FuncBenchmarkCollector(b, mssql.Name, mssql.NewWithFlags)
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, mssql.New, nil)
}