Document possible values of schema fields (#455)
* Document possible values of schema fields * Change from possible to supported
This commit is contained in:
parent
846a2ba181
commit
3fb28d1248
10 changed files with 76 additions and 15 deletions
|
|
@ -76,3 +76,17 @@ func SimplifyBackupSchedule(schedule string) string {
|
|||
})
|
||||
return simplifiedSchedule
|
||||
}
|
||||
|
||||
func SupportedValuesDocumentation(values []string) string {
|
||||
if len(values) == 0 {
|
||||
return ""
|
||||
}
|
||||
return "Supported values are: " + strings.Join(quoteValues(values), ", ") + "."
|
||||
}
|
||||
|
||||
func quoteValues(values []string) []string {
|
||||
for i, value := range values {
|
||||
values[i] = fmt.Sprintf("`%s`", value)
|
||||
}
|
||||
return values
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,3 +192,36 @@ 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue