From 68ecec15e185cb5305a71a5ea3d3ba3365fe0492 Mon Sep 17 00:00:00 2001 From: Shawn O'Dell Date: Sun, 22 Jan 2023 17:03:33 -0600 Subject: [PATCH] use t.Setenv Co-authored-by: Chris Bandy Signed-off-by: Shawn O'Dell --- pkg/test/utils/translate_test.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/test/utils/translate_test.go b/pkg/test/utils/translate_test.go index 202e3ded..8b53b3f7 100644 --- a/pkg/test/utils/translate_test.go +++ b/pkg/test/utils/translate_test.go @@ -3,7 +3,6 @@ package utils import ( "bytes" "fmt" - "os" "testing" "github.com/stretchr/testify/assert" @@ -23,13 +22,9 @@ func testDecoder(s string) *unstructured.Unstructured { func TestTranslate(t *testing.T) { namespace := "foo" - if err := os.Setenv("NAMESPACE", namespace); err != nil { - fmt.Println(err) - } - BAZ := "bar" - if err := os.Setenv("BAZ", BAZ); err != nil { - fmt.Println(err) - } + t.Setenv("NAMESPACE", namespace) + baz := "bar" + t.Setenv("BAZ", baz) manifestTemplate := ` apiVersion: example.com/v1 @@ -61,7 +56,7 @@ spec: key2: %s key2: key1: %s -`, namespace, BAZ, namespace) +`, namespace, baz, namespace) assert.Equal(t, fmt.Sprint(testDecoder(manifestTemplated)), fmt.Sprint(Translate(testDecoder(manifestTemplate)))) }