Skip to content
Snippets Groups Projects
Unverified Commit 90a2f348 authored by Jess's avatar Jess Committed by GitHub
Browse files

Merge pull request #331 from jessicayuen/consistent-params

Set param boolean types as strings
parents 6edb7b93 daf10a0a
No related branches found
No related tags found
No related merge requests found
......@@ -94,10 +94,6 @@ func (c *ParamSetCmd) Run() error {
// sanitizeParamValue does a best effort to identify value types. It will put
// quotes around values which it categorizes as strings.
func sanitizeParamValue(value string) string {
// boolean
if value == "true" || value == "false" {
return value
}
// numeric
if _, err := strconv.ParseFloat(value, 64); err == nil {
return value
......
......@@ -82,3 +82,35 @@ func TestDiffParams(t *testing.T) {
}
}
}
func TestSanitizeParamValue(t *testing.T) {
tests := []struct {
value string
expected string
}{
// numbers
{
value: "64.5",
expected: "64.5",
},
{
value: "64",
expected: "64",
},
// boolean
{
value: "false",
expected: `"false"`,
},
// string
{
value: "my string",
expected: `"my string"`,
},
}
for _, te := range tests {
got := sanitizeParamValue(te.value)
require.Equal(t, got, te.expected, "Unexpected sanitized param value")
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment