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

Function TestLsJSONDeletedEntryIsStructured

cmd/ls_test.go:559–616  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

557}
558
559func TestLsJSONDeletedEntryIsStructured(t *testing.T) {
560 cmd, stdout := testLsCmd(t)
561 setLsOutputJSON(t, cmd)
562 setLsFlag(t, cmd, "include-deleted", "true")
563
564 mock := &mockFilesClient{
565 listFolderFn: func(arg *files.ListFolderArg) (*files.ListFolderResult, error) {
566 return &files.ListFolderResult{
567 Entries: []files.IsMetadata{
568 &files.DeletedMetadata{
569 Metadata: files.Metadata{
570 PathDisplay: "/removed.txt",
571 PathLower: "/removed.txt",
572 },
573 },
574 },
575 HasMore: false,
576 }, nil
577 },
578 listRevisionsFn: func(arg *files.ListRevisionsArg) (*files.ListRevisionsResult, error) {
579 if arg.Path != "/removed.txt" {
580 t.Fatalf("ListRevisions path = %q, want /removed.txt", arg.Path)
581 }
582 return files.NewListRevisionsResult(false, []*files.FileMetadata{
583 {
584 Metadata: files.Metadata{
585 PathDisplay: "/removed.txt",
586 PathLower: "/removed.txt",
587 },
588 Rev: "rev-removed",
589 Size: 9,
590 },
591 }, false), nil
592 },
593 }
594 stubFilesClient(t, mock)
595
596 if err := ls(cmd, nil); err != nil {
597 t.Fatalf("ls error: %v", err)
598 }
599 got := decodeLsOutput(t, stdout)
600 if len(got.Results) != 1 {
601 t.Fatalf("results = %d, want 1", len(got.Results))
602 }
603 if got.Results[0].Status != lsJSONStatusListed || got.Results[0].Kind != "file" {
604 t.Fatalf("result = %#v, want listed file", got.Results[0])
605 }
606 entry := got.Results[0].Result
607 if entry.PathDisplay != "/removed.txt" {
608 t.Fatalf("path_display = %q, want undecorated path", entry.PathDisplay)
609 }
610 if !entry.Deleted {
611 t.Fatal("deleted = false, want true")
612 }
613 if strings.Contains(stdout.String(), "<<") {
614 t.Fatalf("JSON output = %s, want no text deleted marker", stdout.String())
615 }
616}

Callers

nothing calls this directly

Calls 6

testLsCmdFunction · 0.85
setLsOutputJSONFunction · 0.85
setLsFlagFunction · 0.85
stubFilesClientFunction · 0.85
lsFunction · 0.85
decodeLsOutputFunction · 0.85

Tested by

no test coverage detected