github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/tools/doc-generator/util_test.go (about) 1 package main 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_findFlagsPrefix(t *testing.T) { 10 tests := []struct { 11 input []string 12 expected []string 13 }{ 14 { 15 input: []string{}, 16 expected: []string{}, 17 }, 18 { 19 input: []string{""}, 20 expected: []string{""}, 21 }, 22 { 23 input: []string{"", ""}, 24 expected: []string{"", ""}, 25 }, 26 { 27 input: []string{"foo", "foo", "foo"}, 28 expected: []string{"", "", ""}, 29 }, 30 { 31 input: []string{"ruler.endpoint", "alertmanager.endpoint"}, 32 expected: []string{"ruler", "alertmanager"}, 33 }, 34 { 35 input: []string{"ruler.endpoint.address", "alertmanager.endpoint.address"}, 36 expected: []string{"ruler", "alertmanager"}, 37 }, 38 { 39 input: []string{"ruler.first.address", "ruler.second.address"}, 40 expected: []string{"ruler.first", "ruler.second"}, 41 }, 42 } 43 44 for _, test := range tests { 45 assert.Equal(t, test.expected, findFlagsPrefix(test.input)) 46 } 47 }