MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestRevsJSONOutputsInputAndResults

Function TestRevsJSONOutputsInputAndResults

cmd/revs_test.go:104–164  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

102}
103
104func TestRevsJSONOutputsInputAndResults(t *testing.T) {
105 cmd, stdout := testRevsCmd()
106 setRevsOutputJSON(t, cmd)
107 setRevsFlag(t, cmd, "long", "true")
108 setRevsFlag(t, cmd, "limit", "25")
109 setRevsFlag(t, cmd, "time", "client")
110 setRevsFlag(t, cmd, "time-format", "rfc3339")
111 var gotPath string
112 var gotLimit uint64
113 clientModified := time.Date(2026, 6, 22, 10, 0, 0, 0, time.UTC)
114
115 stubFilesClient(t, &mockFilesClient{
116 listRevisionsFn: func(arg *files.ListRevisionsArg) (*files.ListRevisionsResult, error) {
117 gotPath = arg.Path
118 gotLimit = arg.Limit
119 return files.NewListRevisionsResult(false, []*files.FileMetadata{
120 {
121 Metadata: files.Metadata{
122 PathDisplay: "/report.pdf",
123 PathLower: "/report.pdf",
124 },
125 Id: "id:file",
126 Rev: "rev-a",
127 Size: 42,
128 ClientModified: dropbox.DBXTime(clientModified),
129 },
130 }, false), nil
131 },
132 })
133
134 if err := revs(cmd, []string{"/report.pdf"}); err != nil {
135 t.Fatalf("revs returned error: %v", err)
136 }
137 if gotPath != "/report.pdf" {
138 t.Fatalf("ListRevisions path = %q, want /report.pdf", gotPath)
139 }
140 if gotLimit != 25 {
141 t.Fatalf("ListRevisions limit = %d, want 25", gotLimit)
142 }
143
144 got := decodeRevsOutput(t, stdout)
145 if got.Input.Path != "/report.pdf" || got.Input.Limit != 25 || !got.Input.Long || got.Input.Time != "client" || got.Input.TimeFormat != "rfc3339" {
146 t.Fatalf("input = %#v, want path/long/time/time_format", got.Input)
147 }
148 if len(got.Results) != 1 {
149 t.Fatalf("results = %d, want 1", len(got.Results))
150 }
151 if got.Results[0].Status != revsJSONStatusRevision || got.Results[0].Kind != "file" {
152 t.Fatalf("result = %#v, want revision file", got.Results[0])
153 }
154 entry := got.Results[0].Result
155 if entry.Type != "file" || entry.PathDisplay != "/report.pdf" || entry.Rev != "rev-a" || entry.Size == nil || *entry.Size != 42 {
156 t.Fatalf("entry = %#v, want file revision metadata", entry)
157 }
158 if entry.ClientModified == nil || *entry.ClientModified != "2026-06-22T10:00:00Z" {
159 t.Fatalf("client_modified = %#v, want RFC3339 timestamp", entry.ClientModified)
160 }
161 if strings.Contains(stdout.String(), `"entries"`) {

Callers

nothing calls this directly

Calls 6

testRevsCmdFunction · 0.85
setRevsOutputJSONFunction · 0.85
setRevsFlagFunction · 0.85
stubFilesClientFunction · 0.85
revsFunction · 0.85
decodeRevsOutputFunction · 0.85

Tested by

no test coverage detected