From f9a884d3f588b84262377d8560003264bc004ddd Mon Sep 17 00:00:00 2001 From: David Eads Date: Wed, 21 Feb 2018 10:25:23 -0500 Subject: [PATCH] adjust filtered object test to reflect old weird behavior --- pkg/kubectl/cmd/resource/get_test.go | 35 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/pkg/kubectl/cmd/resource/get_test.go b/pkg/kubectl/cmd/resource/get_test.go index 0e7f1adf2b9..8696ae1e340 100644 --- a/pkg/kubectl/cmd/resource/get_test.go +++ b/pkg/kubectl/cmd/resource/get_test.go @@ -386,16 +386,32 @@ func TestGetObjectsFiltered(t *testing.T) { flags map[string]string expect string }{ - {args: []string{"pods", "foo"}, flags: map[string]string{"show-all": "true"}, resp: first, expect: "pod/foo\n"}, - {args: []string{"pods", "foo"}, resp: first, expect: "pod/foo\n"}, - {args: []string{"pods"}, resp: pods, expect: "pod/foo\npod/bar\n"}, - {args: []string{"pods/foo"}, flags: map[string]string{"show-all": "false"}, resp: first, expect: "pod/foo\n"}, - {args: []string{"pods"}, flags: map[string]string{"show-all": "false", "output": "yaml"}, resp: pods, expect: "pod/bar\n"}, - {args: []string{}, flags: map[string]string{"show-all": "false", "filename": "../../../../examples/storage/cassandra/cassandra-controller.yaml"}, resp: pods, expect: "pod/foo\npod/bar\n"}, + {args: []string{"pods", "foo"}, resp: first, flags: map[string]string{"show-all": "true"}, + expect: "NAME READY STATUS RESTARTS AGE\nfoo 0/0 Failed 0 \n"}, - {args: []string{"pods"}, flags: map[string]string{"show-all": "false"}, resp: pods, expect: "pod/bar\n"}, - {args: []string{"pods"}, flags: map[string]string{"show-all": "true", "output": "yaml"}, resp: pods, expect: "pod/foo\npod/bar\n"}, - {args: []string{"pods"}, flags: map[string]string{"show-all": "false"}, resp: pods, expect: "pod/bar\n"}, + {args: []string{"pods", "foo"}, flags: map[string]string{"show-all": "false"}, resp: first, + expect: "NAME READY STATUS RESTARTS AGE\nfoo 0/0 Failed 0 \n"}, + + {args: []string{"pods"}, flags: map[string]string{"show-all": "true"}, resp: pods, + expect: "NAME READY STATUS RESTARTS AGE\nfoo 0/0 Failed 0 \nbar 0/0 0 \n"}, + + {args: []string{"pods/foo"}, resp: first, flags: map[string]string{"show-all": "false"}, + expect: "NAME READY STATUS RESTARTS AGE\nfoo 0/0 Failed 0 \n"}, + + {args: []string{"pods"}, flags: map[string]string{"show-all": "false", "output": "name"}, resp: pods, + expect: "pod/foo\npod/bar\n"}, + + {args: []string{}, flags: map[string]string{"show-all": "false", "filename": "../../../../examples/storage/cassandra/cassandra-controller.yaml"}, resp: pods, + expect: "NAME READY STATUS RESTARTS AGE\nfoo 0/0 Failed 0 \nbar 0/0 0 \n"}, + + {args: []string{"pods"}, resp: pods, flags: map[string]string{"show-all": "false"}, + expect: "NAME READY STATUS RESTARTS AGE\nbar 0/0 0 \n"}, + + {args: []string{"pods"}, flags: map[string]string{"show-all": "true", "output": "name"}, resp: pods, + expect: "pod/foo\npod/bar\n"}, + + {args: []string{"pods"}, flags: map[string]string{"show-all": "false"}, resp: pods, + expect: "NAME READY STATUS RESTARTS AGE\nbar 0/0 0 \n"}, } for i, test := range testCases { @@ -417,7 +433,6 @@ func TestGetObjectsFiltered(t *testing.T) { for k, v := range test.flags { cmd.Flags().Lookup(k).Value.Set(v) } - cmd.Flags().Set("output", "name") cmd.Run(cmd, test.args) if e, a := test.expect, buf.String(); e != a {