goldie icon indicating copy to clipboard operation
goldie copied to clipboard

-update flag doing nothing

Open danawoodman opened this issue 5 years ago • 3 comments

I have a test file like:

// +build e2e

package e2e

import (
	"testing"

	"github.com/sebdah/goldie/v2"
)

func TestFoo(t *testing.T) {
	g := goldie.New(t)
	out := []byte("some-text")
	g.Assert(t, "example", out)
}

And I am running:

go test -tags=e2e -update -clean ./...

And the output is:

?   	github.com/myrepo/myproj	[no test files]

I would expect it to create the golden file but it does nothing. If I remove the -update flag the the test runs but fails because of no golden file.

Manually creating the golden file does work but I cannot get the -update flag to create the file.

I am using v2.

Any ideas what I am doing wrong?

danawoodman avatar Dec 23 '19 20:12 danawoodman

@danawoodman I am not sure that -update does not work, but this is solved by adding flags after ./...

wreulicke avatar Apr 14 '21 14:04 wreulicke

I am not sure that -update does not work, but this is solved by adding flags after ./...

Unfortunately, that breaks if you're also testing other packages which don't use goldie:

$ go test ./... -update
flag provided but not defined: -update
[...]

jdemeyer avatar Oct 13 '21 10:10 jdemeyer