(t *testing.T)
| 503 | } |
| 504 | |
| 505 | func TestSharedLinkCreateRejectsEmptyPassword(t *testing.T) { |
| 506 | called := false |
| 507 | stubSharedLinkClient(t, &mockSharedLinkClient{ |
| 508 | createSharedLinkWithSettingsFn: func(arg *sharing.CreateSharedLinkWithSettingsArg) (sharing.IsSharedLinkMetadata, error) { |
| 509 | called = true |
| 510 | return nil, nil |
| 511 | }, |
| 512 | }) |
| 513 | |
| 514 | cmd := &cobra.Command{} |
| 515 | addSharedLinkPasswordFlags(cmd) |
| 516 | if err := cmd.Flags().Set("password", ""); err != nil { |
| 517 | t.Fatalf("set password: %v", err) |
| 518 | } |
| 519 | |
| 520 | err := shareLinkCreate(cmd, []string{"/file.txt"}) |
| 521 | if err == nil || !strings.Contains(err.Error(), "shared link password cannot be empty") { |
| 522 | t.Fatalf("error = %v, want empty password error", err) |
| 523 | } |
| 524 | if called { |
| 525 | t.Fatal("CreateSharedLinkWithSettings should not be called") |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | func TestSharedLinkCreateWithAccessSetsAccess(t *testing.T) { |
| 530 | mock := &mockSharedLinkClient{ |
nothing calls this directly
no test coverage detected