Skip to content

Commit

Permalink
chore: add target to update golden-files for individual tests (#1369)
Browse files Browse the repository at this point in the history
* chore: add make target to update golden-files for individual tests
* Apply suggestions from code review

Signed-off-by: Zain Malik <zmalikshxil@gmail.com>
Co-Authored-By: Marcin Owsiany <mowsiany@D2iQ.com>
Co-authored-by: Marcin Owsiany <marcin@owsiany.pl>
  • Loading branch information
3 people committed Feb 28, 2020
1 parent ef9a786 commit 04941d2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ ifeq (, $(shell which golangci-lint))
endif
golangci-lint run --disable-all -E goimports --fix

.PHONY: update-golden-%
# used to update the golden files present in ./pkg/kudoctl/cmd/testdata
# Requires the individual test name to avoid massive update of all golden files
# example: make update-golden-TestInitCmd_dry
update-golden-%:
go test ./pkg/kudoctl/cmd ./pkg/kudoctl/packages ./pkg/kudoctl/util/repo -v -mod=readonly -run $* --update=true

.PHONY: todo
# Show to-do items per file.
todo:
Expand Down
2 changes: 1 addition & 1 deletion pkg/kudoctl/cmd/package_list_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestParamsLis(t *testing.T) {
func TestParamsList(t *testing.T) {
file := "params-list"
out := &bytes.Buffer{}
cmd := newPackageListParamsCmd(fs, out)
Expand Down
16 changes: 16 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,19 @@ Run tests against a live cluster and do not delete resources after running:
```
go run ./cmd/kubectl-kudo test --start-control-plane=false --skip-delete
```
### Update golden files of the directory testdata

You can update golden files per each test by running `make update-golden-${test-name}`

Examples:
```
make update-golden-TestInitCmd_dry
make update-golden-TestParamsList
```

Running a non-existing test would return a
```
ok github.com/kudobuilder/kudo/pkg/kudoctl/cmd 0.048s [no tests to run]
```

Currently we don't allow to update all golden files through a single `Makefile` target in one go.

0 comments on commit 04941d2

Please sign in to comment.