77 "testing"
88 "time"
99
10+ "github.com/sebdah/goldie/v2"
1011 "github.com/stretchr/testify/assert"
1112 "github.com/stretchr/testify/require"
12- "gotest.tools/golden"
1313)
1414
1515const (
@@ -24,7 +24,7 @@ const (
2424// to the golden file.
2525//
2626// To update golden file, run:
27- // go test ./tests/integration/... -v -test. update-golden -tags=integration -run=^TestCheckHappyPath$
27+ // go test ./tests/integration/... -v -update -tags=integration -run=^TestCheckHappyPath$
2828func TestCheckSuccess (t * testing.T ) {
2929 type Envs map [string ]string
3030 tests := []struct {
@@ -83,7 +83,9 @@ func TestCheckSuccess(t *testing.T) {
8383 require .NoError (t , err )
8484 assert .Equal (t , result .ExitCode , 0 )
8585 normalizedOutput := normalizeTimeDurations (result .Stdout )
86- golden .Assert (t , normalizedOutput , t .Name ()+ ".golden.txt" )
86+
87+ g := goldie .New (t , goldie .WithNameSuffix (".golden.txt" ))
88+ g .Assert (t , t .Name (), []byte (normalizedOutput ))
8789 })
8890 }
8991}
@@ -95,7 +97,7 @@ func TestCheckSuccess(t *testing.T) {
9597// to the golden file.
9698//
9799// To update golden file, run:
98- // go test ./tests/integration/... -v -test. update-golden -tags=integration -run=^TestCheckFailures$
100+ // go test ./tests/integration/... -v -update -tags=integration -run=^TestCheckFailures$
99101func TestCheckFailures (t * testing.T ) {
100102 type Envs map [string ]string
101103 tests := []struct {
@@ -157,7 +159,9 @@ func TestCheckFailures(t *testing.T) {
157159 assert .Equal (t , 3 , result .ExitCode )
158160
159161 normalizedOutput := normalizeTimeDurations (result .Stdout )
160- golden .Assert (t , normalizedOutput , t .Name ()+ ".golden.txt" )
162+
163+ g := goldie .New (t , goldie .WithNameSuffix (".golden.txt" ))
164+ g .Assert (t , t .Name (), []byte (normalizedOutput ))
161165 })
162166 }
163167}
0 commit comments