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

Function TestSharedLinkCreateRequiresExactlyOnePath

cmd/share_create_link_test.go:140–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

138}
139
140func TestSharedLinkCreateRequiresExactlyOnePath(t *testing.T) {
141 tests := []struct {
142 name string
143 args []string
144 }{
145 {name: "missing path", args: nil},
146 {name: "too many paths", args: []string{"/one", "/two"}},
147 }
148
149 for _, tt := range tests {
150 t.Run(tt.name, func(t *testing.T) {
151 called := false
152 stubSharedLinkClient(t, &mockSharedLinkClient{
153 createSharedLinkWithSettingsFn: func(arg *sharing.CreateSharedLinkWithSettingsArg) (sharing.IsSharedLinkMetadata, error) {
154 called = true
155 return nil, nil
156 },
157 })
158
159 err := shareLinkCreate(&cobra.Command{}, tt.args)
160 if err == nil || !strings.Contains(err.Error(), "`share-link create` requires a `path` argument") {
161 t.Fatalf("error = %v, want path argument error", err)
162 }
163 if called {
164 t.Fatal("CreateSharedLinkWithSettings should not be called")
165 }
166 })
167 }
168}
169
170func TestSharedLinkCreateRejectsRootPath(t *testing.T) {
171 called := false

Callers

nothing calls this directly

Calls 3

stubSharedLinkClientFunction · 0.85
shareLinkCreateFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected