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

Function TestPutFileDestinationTrailingSlash

cmd/put_test.go:435–463  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

433}
434
435func TestPutFileDestinationTrailingSlash(t *testing.T) {
436 tmpFile := filepath.Join(t.TempDir(), "a.txt")
437 if err := os.WriteFile(tmpFile, []byte("test"), 0644); err != nil {
438 t.Fatal(err)
439 }
440
441 var uploadedPath string
442 origConfig := config
443 defer func() { config = origConfig }()
444
445 config = testConfig()
446 testClient := &mockFilesClient{
447 uploadFn: func(arg *files.UploadArg, content io.Reader) (*files.FileMetadata, error) {
448 uploadedPath = arg.Path
449 return &files.FileMetadata{}, nil
450 },
451 }
452 origNew := filesNewFunc
453 filesNewFunc = func(_ dropbox.Config) filesClient { return testClient }
454 defer func() { filesNewFunc = origNew }()
455
456 err := put(testPutCmd(), []string{tmpFile, "/folder/"})
457 if err != nil {
458 t.Fatalf("put error: %v", err)
459 }
460 if uploadedPath != "/folder/a.txt" {
461 t.Errorf("uploaded path = %q, want /folder/a.txt", uploadedPath)
462 }
463}
464
465func TestPutArgValidation(t *testing.T) {
466 err := put(testPutCmd(), []string{})

Callers

nothing calls this directly

Calls 3

testConfigFunction · 0.85
putFunction · 0.85
testPutCmdFunction · 0.85

Tested by

no test coverage detected