mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Merge pull request #45698 from zjj2wry/nnn
Automatic merge from submit-queue (batch tested with PRs 45691, 45667, 45698, 45715) testName to head **What this PR does / why we need it**: **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: testName in head, may be can quick location **Release note**: ```release-note ```
This commit is contained in:
commit
230d2473db
@ -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",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
flags: map[string]string{
|
|
||||||
"image": "foo:v2",
|
|
||||||
},
|
|
||||||
args: []string{"foo"},
|
|
||||||
testName: "missing second image name",
|
testName: "missing second image name",
|
||||||
},
|
|
||||||
{
|
|
||||||
flags: map[string]string{
|
flags: map[string]string{
|
||||||
"image": "foo:v2",
|
"image": "foo:v2",
|
||||||
},
|
},
|
||||||
args: []string{"foo", "foo-v2"},
|
args: []string{"foo"},
|
||||||
testName: "valid image example",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
testName: "valid image example",
|
||||||
|
flags: map[string]string{
|
||||||
|
"image": "foo:v2",
|
||||||
|
},
|
||||||
|
args: []string{"foo", "foo-v2"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user