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

Function TestShareLinkUpdateRequiresExactlyOneURL

cmd/share_link_update_test.go:30–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func TestShareLinkUpdateRequiresExactlyOneURL(t *testing.T) {
31 tests := []struct {
32 name string
33 args []string
34 }{
35 {name: "missing URL", args: nil},
36 {name: "too many URLs", args: []string{"https://example.com/one", "https://example.com/two"}},
37 }
38
39 for _, tt := range tests {
40 t.Run(tt.name, func(t *testing.T) {
41 called := false
42 stubSharedLinkClient(t, &mockSharedLinkClient{
43 modifySharedLinkSettingsFn: func(arg *sharing.ModifySharedLinkSettingsArgs) (sharing.IsSharedLinkMetadata, error) {
44 called = true
45 return nil, nil
46 },
47 })
48
49 err := shareLinkUpdate(newShareLinkUpdateTestCommand(nil, nil), tt.args)
50 if err == nil || !strings.Contains(err.Error(), "requires a `url` argument") {
51 t.Fatalf("error = %v, want URL argument error", err)
52 }
53 if called {
54 t.Fatal("ModifySharedLinkSettings should not be called")
55 }
56 })
57 }
58}
59
60func TestShareLinkUpdateRejectsEmptyURL(t *testing.T) {
61 called := false

Callers

nothing calls this directly

Calls 4

stubSharedLinkClientFunction · 0.85
shareLinkUpdateFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected