Clean up testing code of kubectl cmd section
Kubernetes-commit: 69b0b731e9dcfaa3960581165e4550758b0403c6
This commit is contained in:
parent
af66de2262
commit
992e246451
|
|
@ -399,7 +399,6 @@ func TestUpdateAnnotations(t *testing.T) {
|
||||||
func TestAnnotateErrors(t *testing.T) {
|
func TestAnnotateErrors(t *testing.T) {
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
args []string
|
args []string
|
||||||
flags map[string]string
|
|
||||||
errFn func(error) bool
|
errFn func(error) bool
|
||||||
}{
|
}{
|
||||||
"no args": {
|
"no args": {
|
||||||
|
|
@ -446,9 +445,6 @@ func TestAnnotateErrors(t *testing.T) {
|
||||||
cmd.SetOut(bufOut)
|
cmd.SetOut(bufOut)
|
||||||
cmd.SetErr(bufOut)
|
cmd.SetErr(bufOut)
|
||||||
|
|
||||||
for k, v := range testCase.flags {
|
|
||||||
cmd.Flags().Set(k, v)
|
|
||||||
}
|
|
||||||
options := NewAnnotateOptions(iostreams)
|
options := NewAnnotateOptions(iostreams)
|
||||||
err := options.Complete(tf, cmd, testCase.args)
|
err := options.Complete(tf, cmd, testCase.args)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
@ -459,10 +455,10 @@ func TestAnnotateErrors(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if bufOut.Len() > 0 {
|
if bufOut.Len() > 0 {
|
||||||
t.Errorf("buffer should be empty: %s", string(bufOut.Bytes()))
|
t.Errorf("buffer should be empty: %s", bufOut.String())
|
||||||
}
|
}
|
||||||
if bufErr.Len() > 0 {
|
if bufErr.Len() > 0 {
|
||||||
t.Errorf("buffer should be empty: %s", string(bufErr.Bytes()))
|
t.Errorf("buffer should be empty: %s", bufErr.String())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ func TestSetupOutputWriterNoOp(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
_, _, buf, _ := genericclioptions.NewTestIOStreams()
|
_, _, buf, _ := genericclioptions.NewTestIOStreams()
|
||||||
f := cmdtesting.NewTestFactory()
|
f := cmdtesting.NewTestFactory()
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,6 @@ func TestLabelFunc(t *testing.T) {
|
||||||
func TestLabelErrors(t *testing.T) {
|
func TestLabelErrors(t *testing.T) {
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
args []string
|
args []string
|
||||||
flags map[string]string
|
|
||||||
errFn func(error) bool
|
errFn func(error) bool
|
||||||
}{
|
}{
|
||||||
"no args": {
|
"no args": {
|
||||||
|
|
@ -355,9 +354,6 @@ func TestLabelErrors(t *testing.T) {
|
||||||
cmd.SetOut(buf)
|
cmd.SetOut(buf)
|
||||||
cmd.SetErr(buf)
|
cmd.SetErr(buf)
|
||||||
|
|
||||||
for k, v := range testCase.flags {
|
|
||||||
cmd.Flags().Set(k, v)
|
|
||||||
}
|
|
||||||
opts := NewLabelOptions(ioStreams)
|
opts := NewLabelOptions(ioStreams)
|
||||||
err := opts.Complete(tf, cmd, testCase.args)
|
err := opts.Complete(tf, cmd, testCase.args)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue