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

Function TestGetStdout_DashPathDownloads

cmd/pipe_test.go:439–473  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

437}
438
439func TestGetStdout_DashPathDownloads(t *testing.T) {
440 content := "dash content"
441 var stdout bytes.Buffer
442
443 mock := &mockFilesClient{
444 getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) {
445 return &files.FileMetadata{
446 Metadata: files.Metadata{PathDisplay: arg.Path},
447 Size: uint64(len(content)),
448 }, nil
449 },
450 downloadFn: func(arg *files.DownloadArg) (*files.FileMetadata, io.ReadCloser, error) {
451 if arg.Path != "/-" {
452 t.Errorf("download path = %q, want /-", arg.Path)
453 }
454 meta := &files.FileMetadata{
455 Metadata: files.Metadata{PathDisplay: arg.Path},
456 Size: uint64(len(content)),
457 }
458 return meta, io.NopCloser(strings.NewReader(content)), nil
459 },
460 }
461 stubFilesClient(t, mock)
462
463 cmd := testGetCmd()
464 cmd.SetOut(&stdout)
465
466 err := get(cmd, []string{"/-", "-"})
467 if err != nil {
468 t.Fatalf("get /- - error: %v", err)
469 }
470 if stdout.String() != content {
471 t.Errorf("stdout = %q, want %q", stdout.String(), content)
472 }
473}
474
475func TestGetStdout_RejectsFolder(t *testing.T) {
476 mock := &mockFilesClient{

Callers

nothing calls this directly

Calls 3

stubFilesClientFunction · 0.85
testGetCmdFunction · 0.85
getFunction · 0.85

Tested by

no test coverage detected