(t *testing.T)
| 433 | } |
| 434 | |
| 435 | func 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 | |
| 465 | func TestPutArgValidation(t *testing.T) { |
| 466 | err := put(testPutCmd(), []string{}) |
nothing calls this directly
no test coverage detected