github.com/grafana/pyroscope@v1.18.0/tools/doc-generator/parse/util_test.go (about)

     1  // SPDX-License-Identifier: AGPL-3.0-only
     2  // Provenance-includes-location: https://github.com/cortexproject/cortex/blob/master/tools/doc-generator/util_test.go
     3  // Provenance-includes-license: Apache-2.0
     4  // Provenance-includes-copyright: The Cortex Authors.
     5  
     6  package parse
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/stretchr/testify/assert"
    12  )
    13  
    14  func Test_findFlagsPrefix(t *testing.T) {
    15  	tests := []struct {
    16  		input    []string
    17  		expected []string
    18  	}{
    19  		{
    20  			input:    []string{},
    21  			expected: []string{},
    22  		},
    23  		{
    24  			input:    []string{""},
    25  			expected: []string{""},
    26  		},
    27  		{
    28  			input:    []string{"", ""},
    29  			expected: []string{"", ""},
    30  		},
    31  		{
    32  			input:    []string{"foo", "foo", "foo"},
    33  			expected: []string{"", "", ""},
    34  		},
    35  		{
    36  			input:    []string{"ruler.endpoint", "alertmanager.endpoint"},
    37  			expected: []string{"ruler", "alertmanager"},
    38  		},
    39  		{
    40  			input:    []string{"ruler.endpoint.address", "alertmanager.endpoint.address"},
    41  			expected: []string{"ruler", "alertmanager"},
    42  		},
    43  		{
    44  			input:    []string{"ruler.first.address", "ruler.second.address"},
    45  			expected: []string{"ruler.first", "ruler.second"},
    46  		},
    47  	}
    48  
    49  	for _, test := range tests {
    50  		assert.Equal(t, test.expected, FindFlagsPrefix(test.input))
    51  	}
    52  }