Merge mssql and dfsr expandEnabledCollectors func

Move to common collector.go and add function test.

Signed-off-by: Ben Reedy <breed808@breed808.com>
This commit is contained in:
Ben Reedy
2020-12-03 20:20:28 +10:00
parent ccac306c2d
commit b5ce53fdac
4 changed files with 57 additions and 35 deletions

View File

@@ -0,0 +1,34 @@
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)
}
})
}
}