1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-09 17:37:12 +00:00
kyverno/vendor/gotest.tools/assert/cmd/gty-migrate-from-testify/main_test.go

54 lines
1.2 KiB
Go
Raw Normal View History

2019-06-03 15:07:38 -07:00
package main
import (
"io/ioutil"
"testing"
"github.com/google/go-cmp/cmp"
"gotest.tools/assert"
"gotest.tools/env"
"gotest.tools/fs"
"gotest.tools/golden"
)
func TestRun(t *testing.T) {
setupLogging(&options{})
dir := fs.NewDir(t, "test-run",
fs.WithDir("src/example.com/example", fs.FromDir("testdata/full")))
defer dir.Remove()
defer env.Patch(t, "GO111MODULE", "off")()
defer env.Patch(t, "GOPATH", dir.Path())()
err := run(options{
pkgs: []string{"example.com/example"},
showLoaderErrors: true,
})
assert.NilError(t, err)
raw, err := ioutil.ReadFile(dir.Join("src/example.com/example/some_test.go"))
assert.NilError(t, err)
golden.Assert(t, string(raw), "full-expected/some_test.go")
}
func TestSetupFlags(t *testing.T) {
flags, opts := setupFlags("testing")
assert.Assert(t, flags.Usage != nil)
err := flags.Parse([]string{
"--dry-run",
"--debug",
"--cmp-pkg-import-alias=foo",
"--print-loader-errors",
})
assert.NilError(t, err)
expected := &options{
dryRun: true,
debug: true,
cmpImportName: "foo",
showLoaderErrors: true,
}
assert.DeepEqual(t, opts, expected, cmpOptions)
}
var cmpOptions = cmp.AllowUnexported(options{})