Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up testing code of kubectl cmd section #113444

Merged
merged 1 commit into from Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions staging/src/k8s.io/kubectl/pkg/cmd/annotate/annotate_test.go
Expand Up @@ -383,7 +383,6 @@ func TestUpdateAnnotations(t *testing.T) {
func TestAnnotateErrors(t *testing.T) {
testCases := map[string]struct {
args []string
flags map[string]string
errFn func(error) bool
}{
"no args": {
Expand Down Expand Up @@ -430,9 +429,6 @@ func TestAnnotateErrors(t *testing.T) {
cmd.SetOut(bufOut)
cmd.SetErr(bufOut)

for k, v := range testCase.flags {
cmd.Flags().Set(k, v)
}
options := NewAnnotateOptions(iostreams)
err := options.Complete(tf, cmd, testCase.args)
if err == nil {
Expand All @@ -443,10 +439,10 @@ func TestAnnotateErrors(t *testing.T) {
return
}
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 {
t.Errorf("buffer should be empty: %s", string(bufErr.Bytes()))
t.Errorf("buffer should be empty: %s", bufErr.String())
}
})
}
Expand Down
Expand Up @@ -41,7 +41,6 @@ func TestSetupOutputWriterNoOp(t *testing.T) {
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
_, _, buf, _ := genericclioptions.NewTestIOStreams()
f := cmdtesting.NewTestFactory()
Expand Down
4 changes: 0 additions & 4 deletions staging/src/k8s.io/kubectl/pkg/cmd/label/label_test.go
Expand Up @@ -301,7 +301,6 @@ func TestLabelFunc(t *testing.T) {
func TestLabelErrors(t *testing.T) {
testCases := map[string]struct {
args []string
flags map[string]string
errFn func(error) bool
}{
"no args": {
Expand Down Expand Up @@ -355,9 +354,6 @@ func TestLabelErrors(t *testing.T) {
cmd.SetOut(buf)
cmd.SetErr(buf)

for k, v := range testCase.flags {
cmd.Flags().Set(k, v)
}
opts := NewLabelOptions(ioStreams)
err := opts.Complete(tf, cmd, testCase.args)
if err == nil {
Expand Down