(t *testing.T)
| 831 | } |
| 832 | |
| 833 | func 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 | |
| 873 | func TestDefaultConsumeRequest(t *testing.T) { |
| 874 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…