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

Function TestRevsRejectsInvalidListOptions

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

Source from the content-addressed store, hash-verified

182}
183
184func TestRevsRejectsInvalidListOptions(t *testing.T) {
185 tests := []struct {
186 name string
187 flag string
188 value string
189 }{
190 {name: "time", flag: "time", value: "created"},
191 {name: "time-format", flag: "time-format", value: "unix"},
192 }
193
194 for _, tt := range tests {
195 t.Run(tt.name, func(t *testing.T) {
196 cmd, stdout := testRevsCmd()
197 setRevsFlag(t, cmd, tt.flag, tt.value)
198 stubFilesClient(t, &mockFilesClient{
199 listRevisionsFn: func(arg *files.ListRevisionsArg) (*files.ListRevisionsResult, error) {
200 t.Fatalf("ListRevisions called for invalid --%s", tt.flag)
201 return nil, nil
202 },
203 })
204
205 err := revs(cmd, []string{"/report.pdf"})
206 if err == nil {
207 t.Fatalf("expected invalid --%s error", tt.flag)
208 }
209 if !strings.Contains(err.Error(), tt.flag) || !strings.Contains(err.Error(), tt.value) {
210 t.Fatalf("error = %v, want flag and value", err)
211 }
212 if got := stdout.String(); got != "" {
213 t.Fatalf("stdout = %q, want empty output on validation error", got)
214 }
215 })
216 }
217}
218
219func TestRevsCommandSupportsStructuredOutput(t *testing.T) {
220 if !commandSupportsStructuredOutput(revsCmd) {

Callers

nothing calls this directly

Calls 5

testRevsCmdFunction · 0.85
setRevsFlagFunction · 0.85
stubFilesClientFunction · 0.85
revsFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected