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

Function TestPutLocalDashFile

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

Source from the content-addressed store, hash-verified

359}
360
361func TestPutLocalDashFile(t *testing.T) {
362 // put ./- /remote uploads a local file named "-"
363 tmpDir := t.TempDir()
364 dashFile := tmpDir + "/-"
365 if err := writeTestFile(dashFile, "local dash file"); err != nil {
366 t.Fatal(err)
367 }
368
369 var uploadedPath string
370 origConfig := config
371 defer func() { config = origConfig }()
372 config = testConfig()
373
374 testClient := &mockFilesClient{
375 getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) {
376 return nil, &files.GetMetadataAPIError{}
377 },
378 uploadFn: func(arg *files.UploadArg, r io.Reader) (*files.FileMetadata, error) {
379 uploadedPath = arg.Path
380 _, _ = io.ReadAll(r)
381 return &files.FileMetadata{}, nil
382 },
383 }
384 origNew := filesNewFunc
385 filesNewFunc = func(_ dropbox.Config) filesClient { return testClient }
386 defer func() { filesNewFunc = origNew }()
387
388 cmd := testPutCmd()
389 err := put(cmd, []string{dashFile, "/remote"})
390 if err != nil {
391 t.Fatalf("put ./ - error: %v", err)
392 }
393 if uploadedPath != "/remote" {
394 t.Errorf("uploaded path = %q, want /remote", uploadedPath)
395 }
396}
397
398// --- get stdout tests ---
399

Callers

nothing calls this directly

Calls 4

writeTestFileFunction · 0.85
testConfigFunction · 0.85
testPutCmdFunction · 0.85
putFunction · 0.85

Tested by

no test coverage detected