MCPcopy
hub / github.com/kubernetes/kubectl / TestLogComplete

Function TestLogComplete

pkg/cmd/logs/logs_test.go:833–871  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

831}
832
833func TestLogComplete(t *testing.T) {
834 f := cmdtesting.NewTestFactory()
835 defer f.Cleanup()
836
837 tests := []struct {
838 name string
839 args []string
840 opts func(genericiooptions.IOStreams) *LogsOptions
841 expected string
842 }{
843 {
844 name: "One args case",
845 args: []string{"foo"},
846 opts: func(streams genericiooptions.IOStreams) *LogsOptions {
847 o := NewLogsOptions(streams)
848 o.Selector = "foo"
849 return o
850 },
851 expected: "only a selector (-l) or a POD name is allowed",
852 },
853 }
854 for _, test := range tests {
855 cmd := NewCmdLogs(f, genericiooptions.NewTestIOStreamsDiscard())
856 out := ""
857
858 // checkErr breaks tests in case of errors, plus we just
859 // need to check errors returned by the command validation
860 o := test.opts(genericiooptions.NewTestIOStreamsDiscard())
861 err := o.Complete(f, cmd, test.args)
862 if err == nil {
863 t.Fatalf("expected error %q, got none", test.expected)
864 }
865
866 out = err.Error()
867 if !strings.Contains(out, test.expected) {
868 t.Errorf("%s: expected to find:\n\t%s\nfound:\n\t%s\n", test.name, test.expected, out)
869 }
870 }
871}
872
873func TestDefaultConsumeRequest(t *testing.T) {
874 tests := []struct {

Callers

nothing calls this directly

Calls 5

CleanupMethod · 0.95
CompleteMethod · 0.95
NewLogsOptionsFunction · 0.85
NewCmdLogsFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…