More tests, better errors.

This commit is contained in:
jregan
2019-11-26 18:13:15 -08:00
parent a2b84fce86
commit f3e735153f
22 changed files with 112 additions and 59 deletions

View File

@@ -80,8 +80,6 @@ func NewCmdBuild(out io.Writer) *cobra.Command {
return cmd
}
const CWD = "."
// Validate validates build command.
func (o *Options) Validate(args []string) (err error) {
if len(args) > 1 {
@@ -90,7 +88,7 @@ func (o *Options) Validate(args []string) (err error) {
konfig.DefaultKustomizationFileName())
}
if len(args) == 0 {
o.kustomizationPath = CWD
o.kustomizationPath = filesys.SelfDir
} else {
o.kustomizationPath = args[0]
}

View File

@@ -6,6 +6,7 @@ package build
import (
"testing"
"sigs.k8s.io/kustomize/api/filesys"
"sigs.k8s.io/kustomize/api/konfig"
)
@@ -22,7 +23,7 @@ func TestBuildValidate(t *testing.T) {
path string
erMsg string
}{
{"noargs", []string{}, ".", ""},
{"noargs", []string{}, filesys.SelfDir, ""},
{"file", []string{"beans"}, "beans", ""},
{"path", []string{"a/b/c"}, "a/b/c", ""},
{"path", []string{"too", "many"},

View File

@@ -31,7 +31,7 @@ type createFlags struct {
// NewCmdCreate returns an instance of 'create' subcommand.
func NewCmdCreate(fSys filesys.FileSystem, uf ifc.KunstructuredFactory) *cobra.Command {
opts := createFlags{path: "."}
opts := createFlags{path: filesys.SelfDir}
c := &cobra.Command{
Use: "create",
Short: "Create a new kustomization in the current directory",