small change to clear

This commit is contained in:
zhengjiajin 2017-05-11 20:09:12 +08:00
parent 640373da10
commit 77c207b424

View File

@ -27,49 +27,49 @@ func TestValidateArgs(t *testing.T) {
f, _, _, _ := cmdtesting.NewAPIFactory() f, _, _, _ := cmdtesting.NewAPIFactory()
tests := []struct { tests := []struct {
testName string
flags map[string]string flags map[string]string
filenames []string filenames []string
args []string args []string
expectErr bool expectErr bool
testName string
}{ }{
{ {
expectErr: true,
testName: "nothing", testName: "nothing",
expectErr: true,
}, },
{ {
testName: "no file, no image",
flags: map[string]string{}, flags: map[string]string{},
args: []string{"foo"}, args: []string{"foo"},
expectErr: true, expectErr: true,
testName: "no file, no image",
}, },
{ {
testName: "valid file example",
filenames: []string{"bar.yaml"}, filenames: []string{"bar.yaml"},
args: []string{"foo"}, args: []string{"foo"},
testName: "valid file example",
}, },
{ {
testName: "missing second image name",
flags: map[string]string{ flags: map[string]string{
"image": "foo:v2", "image": "foo:v2",
}, },
args: []string{"foo"}, args: []string{"foo"},
testName: "missing second image name",
}, },
{ {
testName: "valid image example",
flags: map[string]string{ flags: map[string]string{
"image": "foo:v2", "image": "foo:v2",
}, },
args: []string{"foo", "foo-v2"}, args: []string{"foo", "foo-v2"},
testName: "valid image example",
}, },
{ {
testName: "both filename and image example",
flags: map[string]string{ flags: map[string]string{
"image": "foo:v2", "image": "foo:v2",
}, },
filenames: []string{"bar.yaml"}, filenames: []string{"bar.yaml"},
args: []string{"foo", "foo-v2"}, args: []string{"foo", "foo-v2"},
expectErr: true, expectErr: true,
testName: "both filename and image example",
}, },
} }
for _, test := range tests { for _, test := range tests {
@ -83,10 +83,10 @@ func TestValidateArgs(t *testing.T) {
} }
err := validateArguments(cmd, test.filenames, test.args) err := validateArguments(cmd, test.filenames, test.args)
if err != nil && !test.expectErr { if err != nil && !test.expectErr {
t.Errorf("unexpected error: %v (%s)", err, test.testName) t.Errorf("%s: unexpected error: %v", test.testName, err)
} }
if err == nil && test.expectErr { if err == nil && test.expectErr {
t.Errorf("unexpected non-error (%s)", test.testName) t.Errorf("%s: unexpected non-error", test.testName)
} }
} }
} }