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

Function TestRestoreJSONErrorWritesNoOutput

cmd/restore_test.go:249–270  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

247}
248
249func TestRestoreJSONErrorWritesNoOutput(t *testing.T) {
250 cmd, stdout := testRestoreCmd()
251 setRestoreOutputJSON(t, cmd)
252 mock := &mockFilesClient{
253 restoreFn: func(arg *files.RestoreArg) (*files.FileMetadata, error) {
254 return nil, errors.New("restore failed")
255 },
256 }
257 stubFilesClient(t, mock)
258
259 err := restore(cmd, []string{"/Reports/old.pdf", "target-rev"})
260 if err == nil {
261 t.Fatal("expected restore error")
262 }
263 details := jsonErrorDetails(err)
264 if details["operation"] != "restore" || details["path"] != "/Reports/old.pdf" || details["revision"] != "target-rev" {
265 t.Fatalf("details = %#v, want restore operation, path, and revision", details)
266 }
267 if got := stdout.String(); got != "" {
268 t.Fatalf("stdout = %q, want empty output on error", got)
269 }
270}
271
272func TestRestoreCommandSupportsStructuredOutput(t *testing.T) {
273 if !commandSupportsStructuredOutput(restoreCmd) {

Callers

nothing calls this directly

Calls 5

testRestoreCmdFunction · 0.85
setRestoreOutputJSONFunction · 0.85
stubFilesClientFunction · 0.85
restoreFunction · 0.85
jsonErrorDetailsFunction · 0.85

Tested by

no test coverage detected