(t *testing.T)
| 247 | } |
| 248 | |
| 249 | func 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 | |
| 272 | func TestRestoreCommandSupportsStructuredOutput(t *testing.T) { |
| 273 | if !commandSupportsStructuredOutput(restoreCmd) { |
nothing calls this directly
no test coverage detected