refactor(docs): remove duplicate util func to format possible values (#1050)
This commit is contained in:
parent
64d6fa9bea
commit
52b879b436
28 changed files with 30 additions and 77 deletions
|
|
@ -110,20 +110,6 @@ func ConvertPointerSliceToStringSlice(pointerSlice []*string) []string {
|
|||
}
|
||||
return stringSlice
|
||||
}
|
||||
func SupportedValuesDocumentation(values []string) string {
|
||||
if len(values) == 0 {
|
||||
return ""
|
||||
}
|
||||
return "Supported values are: " + strings.Join(QuoteValues(values), ", ") + "."
|
||||
}
|
||||
|
||||
func QuoteValues(values []string) []string {
|
||||
quotedValues := make([]string, len(values))
|
||||
for i, value := range values {
|
||||
quotedValues[i] = fmt.Sprintf("`%s`", value)
|
||||
}
|
||||
return quotedValues
|
||||
}
|
||||
|
||||
func IsLegacyProjectRole(role string) bool {
|
||||
return utils.Contains(LegacyProjectRoles, role)
|
||||
|
|
|
|||
|
|
@ -253,39 +253,6 @@ func TestSimplifyBackupSchedule(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSupportedValuesDocumentation(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
values []string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
"empty values",
|
||||
[]string{},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"single value",
|
||||
[]string{"value"},
|
||||
"Supported values are: `value`.",
|
||||
},
|
||||
{
|
||||
"multiple values",
|
||||
[]string{"value1", "value2", "value3"},
|
||||
"Supported values are: `value1`, `value2`, `value3`.",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.description, func(t *testing.T) {
|
||||
output := SupportedValuesDocumentation(tt.values)
|
||||
if output != tt.expected {
|
||||
t.Fatalf("Data does not match: %s", output)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsLegacyProjectRole(t *testing.T) {
|
||||
tests := []struct {
|
||||
description string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue