MCPcopy
hub / github.com/larksuite/cli / TestValidateFileFlag

Function TestValidateFileFlag

internal/cmdutil/fileupload_test.go:149–263  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

147}
148
149func TestValidateFileFlag(t *testing.T) {
150 tests := []struct {
151 name string
152 file string
153 params string
154 data string
155 outputPath string
156 pageAll bool
157 httpMethod string
158 wantErr string // empty means no error
159 }{
160 {
161 name: "empty file is valid",
162 file: "",
163 httpMethod: "GET",
164 wantErr: "",
165 },
166 {
167 name: "empty file path",
168 file: "field=",
169 httpMethod: "POST",
170 wantErr: "--file: empty file path",
171 },
172 {
173 name: "file with output",
174 file: "photo.jpg",
175 outputPath: "out.json",
176 httpMethod: "POST",
177 wantErr: "--file and --output are mutually exclusive",
178 },
179 {
180 name: "file with page-all",
181 file: "photo.jpg",
182 pageAll: true,
183 httpMethod: "POST",
184 wantErr: "--file and --page-all are mutually exclusive",
185 },
186 {
187 name: "stdin file with stdin data",
188 file: "-",
189 data: "-",
190 httpMethod: "POST",
191 wantErr: "--file and --data cannot both read from stdin",
192 },
193 {
194 name: "stdin file with stdin params",
195 file: "-",
196 params: "-",
197 httpMethod: "POST",
198 wantErr: "--file and --params cannot both read from stdin",
199 },
200 {
201 name: "file with GET method",
202 file: "photo.jpg",
203 httpMethod: "GET",
204 wantErr: "--file requires POST, PUT, PATCH, or DELETE method",
205 },
206 {

Callers

nothing calls this directly

Calls 5

ValidateFileFlagFunction · 0.85
RunMethod · 0.65
ContainsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected