provide standard iostream struct for commands

This commit is contained in:
David Eads
2018-04-19 17:43:28 -04:00
parent 9c60fd5242
commit 8ef56776b9
45 changed files with 431 additions and 436 deletions

View File

@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl"
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
)
func Test_generatorFromName(t *testing.T) {
@@ -104,9 +105,9 @@ func TestCreateDeployment(t *testing.T) {
}
tf.ClientConfigVal = &restclient.Config{}
tf.Namespace = "test"
buf := bytes.NewBuffer([]byte{})
cmd := NewCmdCreateDeployment(tf, buf, buf)
ioStreams, _, buf, _ := genericclioptions.NewTestIOStreams()
cmd := NewCmdCreateDeployment(tf, ioStreams)
cmd.Flags().Set("dry-run", "true")
cmd.Flags().Set("output", "name")
cmd.Flags().Set("image", "hollywood/jonny.depp:v2")
@@ -136,16 +137,14 @@ func TestCreateDeploymentNoImage(t *testing.T) {
tf.ClientConfigVal = &restclient.Config{}
tf.Namespace = "test"
buf := bytes.NewBuffer([]byte{})
errBuff := bytes.NewBuffer([]byte{})
cmd := NewCmdCreateDeployment(tf, buf, errBuff)
ioStreams := genericclioptions.NewTestIOStreamsDiscard()
cmd := NewCmdCreateDeployment(tf, ioStreams)
cmd.Flags().Set("output", "name")
options := &DeploymentOpts{
CreateSubcommandOptions: &CreateSubcommandOptions{
PrintFlags: NewPrintFlags("created"),
CmdOut: buf,
CmdErr: errBuff,
DryRun: true,
IOStreams: ioStreams,
},
}