Skip to content

Commit

Permalink
Adding simple test to AnyToString as well
Browse files Browse the repository at this point in the history
  • Loading branch information
janboll committed Nov 25, 2024
1 parent 2c6b1ba commit abe34fb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tooling/templatize/pkg/utils/typing.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package utils

import "fmt"
import (
"fmt"
)

// AnyToString maps some types to strings, as they are used in OS Env.
func AnyToString(value any) string {
switch v := value.(type) {
case string:
Expand Down
14 changes: 14 additions & 0 deletions tooling/templatize/pkg/utils/typing_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package utils

import (
"testing"

"gotest.tools/assert"
)

func TestAnyToString(t *testing.T) {
assert.Equal(t, "foo", AnyToString("foo"))
assert.Equal(t, "42", AnyToString(42))
assert.Equal(t, "true", AnyToString(true))
assert.Equal(t, "3.14", AnyToString(3.14))
}

0 comments on commit abe34fb

Please sign in to comment.