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

Function TestGetJSONExistingDirectoryTargetAppendsBasename

cmd/get_test.go:684–711  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

682}
683
684func TestGetJSONExistingDirectoryTargetAppendsBasename(t *testing.T) {
685 tmpDir := t.TempDir()
686
687 mock := &mockFilesClient{
688 getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) {
689 return getTestFileMetadata(arg.Path, 4), nil
690 },
691 downloadFn: func(arg *files.DownloadArg) (*files.FileMetadata, io.ReadCloser, error) {
692 return getTestFileMetadata(arg.Path, 4), io.NopCloser(strings.NewReader("data")), nil
693 },
694 }
695 stubFilesClient(t, mock)
696
697 var stdout bytes.Buffer
698 cmd := testGetJSONCmd(&stdout, nil)
699 if err := get(cmd, []string{"/remote/file.txt", tmpDir}); err != nil {
700 t.Fatalf("get error: %v", err)
701 }
702
703 wantTarget := filepath.Join(tmpDir, "file.txt")
704 got := decodeGetOutput(t, &stdout)
705 if got.Input.Target != wantTarget {
706 t.Fatalf("target = %q, want %q", got.Input.Target, wantTarget)
707 }
708 if got.Results[0].Input.Target != wantTarget {
709 t.Fatalf("result target = %q, want %q", got.Results[0].Input.Target, wantTarget)
710 }
711}
712
713func TestGetJSONRejectsStdoutTarget(t *testing.T) {
714 var stdout bytes.Buffer

Callers

nothing calls this directly

Calls 5

getTestFileMetadataFunction · 0.85
stubFilesClientFunction · 0.85
testGetJSONCmdFunction · 0.85
getFunction · 0.85
decodeGetOutputFunction · 0.85

Tested by

no test coverage detected