update more commands for iostreams
This commit is contained in:
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package set
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
@@ -42,6 +41,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
"k8s.io/kubernetes/pkg/kubectl/resource"
|
||||
"k8s.io/kubernetes/pkg/kubectl/scheme"
|
||||
)
|
||||
@@ -65,8 +65,8 @@ func TestImageLocal(t *testing.T) {
|
||||
|
||||
outputFormat := "name"
|
||||
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
cmd := NewCmdImage(tf, buf, buf)
|
||||
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
||||
cmd := NewCmdImage(tf, streams)
|
||||
cmd.SetOutput(buf)
|
||||
cmd.Flags().Set("output", outputFormat)
|
||||
cmd.Flags().Set("local", "true")
|
||||
@@ -80,8 +80,9 @@ func TestImageLocal(t *testing.T) {
|
||||
},
|
||||
FilenameOptions: resource.FilenameOptions{
|
||||
Filenames: []string{"../../../../test/e2e/testing-manifests/statefulset/cassandra/controller.yaml"}},
|
||||
Out: buf,
|
||||
Local: true}
|
||||
Local: true,
|
||||
IOStreams: streams,
|
||||
}
|
||||
err := opts.Complete(tf, cmd, []string{"cassandra=thingy"})
|
||||
if err == nil {
|
||||
err = opts.Validate()
|
||||
@@ -187,8 +188,8 @@ func TestSetMultiResourcesImageLocal(t *testing.T) {
|
||||
|
||||
outputFormat := "name"
|
||||
|
||||
buf := bytes.NewBuffer([]byte{})
|
||||
cmd := NewCmdImage(tf, buf, buf)
|
||||
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
|
||||
cmd := NewCmdImage(tf, streams)
|
||||
cmd.SetOutput(buf)
|
||||
cmd.Flags().Set("output", outputFormat)
|
||||
cmd.Flags().Set("local", "true")
|
||||
@@ -202,8 +203,9 @@ func TestSetMultiResourcesImageLocal(t *testing.T) {
|
||||
},
|
||||
FilenameOptions: resource.FilenameOptions{
|
||||
Filenames: []string{"../../../../test/fixtures/pkg/kubectl/cmd/set/multi-resource-yaml.yaml"}},
|
||||
Out: buf,
|
||||
Local: true}
|
||||
Local: true,
|
||||
IOStreams: streams,
|
||||
}
|
||||
err := opts.Complete(tf, cmd, []string{"*=thingy"})
|
||||
if err == nil {
|
||||
err = opts.Validate()
|
||||
@@ -583,9 +585,8 @@ func TestSetImageRemote(t *testing.T) {
|
||||
|
||||
outputFormat := "yaml"
|
||||
|
||||
out := new(bytes.Buffer)
|
||||
cmd := NewCmdImage(tf, out, out)
|
||||
cmd.SetOutput(out)
|
||||
streams := genericclioptions.NewTestIOStreamsDiscard()
|
||||
cmd := NewCmdImage(tf, streams)
|
||||
cmd.Flags().Set("output", outputFormat)
|
||||
opts := SetImageOptions{
|
||||
PrintFlags: &printers.PrintFlags{
|
||||
@@ -595,8 +596,9 @@ func TestSetImageRemote(t *testing.T) {
|
||||
OutputFormat: &outputFormat,
|
||||
},
|
||||
|
||||
Out: out,
|
||||
Local: false}
|
||||
Local: false,
|
||||
IOStreams: streams,
|
||||
}
|
||||
err := opts.Complete(tf, cmd, input.args)
|
||||
assert.NoError(t, err)
|
||||
err = opts.Run()
|
||||
|
Reference in New Issue
Block a user