windows_exporter/collector/collector_test.go
Ben Reedy b5ce53fdac
Merge mssql and dfsr expandEnabledCollectors func
Move to common collector.go and add function test.

Signed-off-by: Ben Reedy <breed808@breed808.com>
2020-12-09 19:55:13 +10:00

35 lines
783 B
Go

package collector
import (
"reflect"
"testing"
)
func TestExpandChildCollectors(t *testing.T) {
cases := []struct {
name string
input string
expectedOutput []string
}{
{
name: "simple",
input: "testing1,testing2,testing3",
expectedOutput: []string{"testing1", "testing2", "testing3"},
},
{
name: "duplicate",
input: "testing1,testing2,testing2,testing3",
expectedOutput: []string{"testing1", "testing2", "testing3"},
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
output := expandEnabledChildCollectors(c.input)
if !reflect.DeepEqual(output, c.expectedOutput) {
t.Errorf("Output mismatch, expected %+v, got %+v", c.expectedOutput, output)
}
})
}
}