Skip to content

Commit

Permalink
use t.Setenv
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Bandy <[email protected]>
Signed-off-by: Shawn O'Dell <[email protected]>
  • Loading branch information
so-jelly and cbandy committed Jan 22, 2023
1 parent b9e4e45 commit 68ecec1
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions pkg/test/utils/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package utils
import (
"bytes"
"fmt"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -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
Expand Down Expand Up @@ -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))))
}

0 comments on commit 68ecec1

Please sign in to comment.