chore: use cast.ToBoolE (#17030)
This commit is contained in:
parent
c6d9e1bed8
commit
f946781c74
2 changed files with 0 additions and 24 deletions
|
|
@ -16,11 +16,6 @@ import (
|
|||
|
||||
var re = regexp.MustCompile(`(?i)\${(\w+)(:([a-zA-Z0-9%.]+))?}`)
|
||||
|
||||
// Truish returns true if value is truish (true/1/on)
|
||||
func Truish(s string) bool {
|
||||
return s == "1" || strings.ToLower(s) == "true" || strings.ToLower(s) == "on"
|
||||
}
|
||||
|
||||
// FormatValue will apply specific formatting in addition to standard sprintf
|
||||
func FormatValue(format string, val interface{}) string {
|
||||
switch typed := val.(type) {
|
||||
|
|
|
|||
|
|
@ -9,25 +9,6 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestTruish(t *testing.T) {
|
||||
cases := []struct {
|
||||
k string
|
||||
v bool
|
||||
}{
|
||||
{"", false},
|
||||
{"false", false},
|
||||
{"0", false},
|
||||
{"off", false},
|
||||
{"true", true},
|
||||
{"1", true},
|
||||
{"on", true},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
assert.Equal(t, c.v, Truish(c.k))
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplace(t *testing.T) {
|
||||
cases := []struct {
|
||||
k string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue