diff --git a/cmd/kubeadm/app/cmd/certs_test.go b/cmd/kubeadm/app/cmd/certs_test.go index 8dff90ad8e2..3b50a6babe4 100644 --- a/cmd/kubeadm/app/cmd/certs_test.go +++ b/cmd/kubeadm/app/cmd/certs_test.go @@ -23,6 +23,7 @@ import ( "crypto" "crypto/x509" "fmt" + "io" "os" "path/filepath" "strings" @@ -269,7 +270,7 @@ func TestRunRenewCommands(t *testing.T) { if len(test.Args) > 0 { args = test.Args + " " + args } - err := cmdtestutil.RunSubCommand(t, renewCmds, test.command, args) + err := cmdtestutil.RunSubCommand(t, renewCmds, test.command, io.Discard, args) // certs renew doesn't support positional Args if (err != nil) != test.expectedError { t.Errorf("failed to run renew commands, expected error: %t, actual error: %v", test.expectedError, err) diff --git a/cmd/kubeadm/test/cmd/util.go b/cmd/kubeadm/test/cmd/util.go index d48e82d1646..7edb9cbf783 100644 --- a/cmd/kubeadm/test/cmd/util.go +++ b/cmd/kubeadm/test/cmd/util.go @@ -18,6 +18,7 @@ package kubeadm import ( "bytes" + "io" "os" "os/exec" "testing" @@ -50,8 +51,9 @@ func RunCmd(command string, args ...string) (string, string, int, error) { } // RunSubCommand is a utility function for kubeadm testing that executes a Cobra sub command -func RunSubCommand(t *testing.T, subCmds []*cobra.Command, command string, args ...string) error { +func RunSubCommand(t *testing.T, subCmds []*cobra.Command, command string, output io.Writer, args ...string) error { subCmd := getSubCommand(t, subCmds, command) + subCmd.SetOut(output) subCmd.SetArgs(args) if err := subCmd.Execute(); err != nil { return err