mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 05:56:37 +00:00
chore: enable more linter (#1557)
This commit is contained in:
@@ -14,13 +14,15 @@ import (
|
||||
// Splits provided child Collectors and deduplicate.
|
||||
func ExpandEnabledChildCollectors(enabled string) []string {
|
||||
result := slices.Compact(strings.Split(enabled, ","))
|
||||
// Ensure result is ordered, to prevent test failure
|
||||
|
||||
// Result must order, to prevent test failures.
|
||||
sort.Strings(result)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func ExpandEnabledCollectors(enabled string) []string {
|
||||
expanded := strings.Replace(enabled, types.DefaultCollectorsPlaceholder, types.DefaultCollectors, -1)
|
||||
expanded := strings.ReplaceAll(enabled, types.DefaultCollectorsPlaceholder, types.DefaultCollectors)
|
||||
separated := strings.Split(expanded, ",")
|
||||
unique := map[string]bool{}
|
||||
for _, s := range separated {
|
||||
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
)
|
||||
|
||||
func TestExpandChildCollectors(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
input string
|
||||
@@ -30,6 +32,8 @@ func TestExpandChildCollectors(t *testing.T) {
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
output := utils.ExpandEnabledChildCollectors(c.input)
|
||||
if !reflect.DeepEqual(output, c.expectedOutput) {
|
||||
t.Errorf("Output mismatch, expected %+v, got %+v", c.expectedOutput, output)
|
||||
@@ -39,6 +43,8 @@ func TestExpandChildCollectors(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExpandEnabled(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
expansionTests := []struct {
|
||||
input string
|
||||
expectedOutput []string
|
||||
|
||||
Reference in New Issue
Block a user