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

Function TestLsJSONFilePathUsesMetadata

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

Source from the content-addressed store, hash-verified

517}
518
519func TestLsJSONFilePathUsesMetadata(t *testing.T) {
520 cmd, stdout := testLsCmd(t)
521 setLsOutputJSON(t, cmd)
522 var metadataPath string
523
524 mock := &mockFilesClient{
525 getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) {
526 metadataPath = arg.Path
527 return &files.FileMetadata{
528 Metadata: files.Metadata{
529 PathDisplay: "/file.txt",
530 PathLower: "/file.txt",
531 },
532 Id: "id:file",
533 Rev: "rev-file",
534 Size: 7,
535 }, nil
536 },
537 listFolderFn: func(arg *files.ListFolderArg) (*files.ListFolderResult, error) {
538 t.Fatalf("ListFolder called for file path: %v", arg)
539 return nil, nil
540 },
541 }
542 stubFilesClient(t, mock)
543
544 if err := ls(cmd, []string{"/file.txt"}); err != nil {
545 t.Fatalf("ls error: %v", err)
546 }
547 if metadataPath != "/file.txt" {
548 t.Fatalf("metadata path = %q, want /file.txt", metadataPath)
549 }
550 got := decodeLsOutput(t, stdout)
551 if got.Input.Path != "/file.txt" {
552 t.Fatalf("input path = %q, want /file.txt", got.Input.Path)
553 }
554 if len(got.Results) != 1 || got.Results[0].Status != lsJSONStatusListed || got.Results[0].Kind != "file" || got.Results[0].Result.Type != "file" {
555 t.Fatalf("results = %#v, want one listed file", got.Results)
556 }
557}
558
559func TestLsJSONDeletedEntryIsStructured(t *testing.T) {
560 cmd, stdout := testLsCmd(t)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected