(t *testing.T)
| 101 | } |
| 102 | |
| 103 | func TestShareLinkListJSONOutputsResultsAndInput(t *testing.T) { |
| 104 | stubSharedLinkClient(t, &mockSharedLinkClient{ |
| 105 | listSharedLinksFn: func(arg *sharing.ListSharedLinksArg) (*sharing.ListSharedLinksResult, error) { |
| 106 | if arg.Path != "/docs/report.txt" || !arg.DirectOnly { |
| 107 | t.Fatalf("ListSharedLinks arg = %#v, want direct path filter", arg) |
| 108 | } |
| 109 | return sharing.NewListSharedLinksResult([]sharing.IsSharedLinkMetadata{ |
| 110 | sharedLinkFile("/docs/report.txt", "https://example.com/report"), |
| 111 | }, false), nil |
| 112 | }, |
| 113 | }) |
| 114 | |
| 115 | var stdout bytes.Buffer |
| 116 | cmd := &cobra.Command{} |
| 117 | cmd.SetOut(&stdout) |
| 118 | setShareLinkOutputJSON(t, cmd) |
| 119 | |
| 120 | if err := shareLinkList(cmd, []string{"/docs/report.txt"}); err != nil { |
| 121 | t.Fatalf("shareLinkList error: %v", err) |
| 122 | } |
| 123 | |
| 124 | got := decodeShareLinkOperationOutput[shareLinkListInput, shareLinkJSONMetadata](t, stdout.Bytes()) |
| 125 | if got.Input.Path != "/docs/report.txt" || !got.Input.DirectOnly { |
| 126 | t.Fatalf("input = %#v, want direct path input", got.Input) |
| 127 | } |
| 128 | if len(got.Results) != 1 || got.Results[0].Status != shareLinkJSONStatusListed || got.Results[0].Kind != "file" || got.Results[0].Result.URL != "https://example.com/report" { |
| 129 | t.Fatalf("results = %#v, want listed report shared link", got.Results) |
| 130 | } |
| 131 | if strings.Contains(stdout.String(), `"entries"`) { |
| 132 | t.Fatalf("JSON output = %s, want operation results and no entries key", stdout.String()) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | func TestDeprecatedShareListLinkJSONIncludesWarning(t *testing.T) { |
| 137 | stubSharedLinkClient(t, &mockSharedLinkClient{ |
nothing calls this directly
no test coverage detected