MCPcopy Create free account
hub / github.com/UiPath/uipathcli / TestUploadLargeFile

Function TestUploadLargeFile

plugin/orchestrator/upload/upload_command_test.go:209–248  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func TestUploadLargeFile(t *testing.T) {
210 size := 10 * 1024 * 1024
211 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
212 body, _ := io.ReadAll(r.Body)
213 if len(body) != size {
214 w.WriteHeader(http.StatusInternalServerError)
215 _, _ = w.Write([]byte("Invalid size"))
216 return
217 }
218 w.WriteHeader(http.StatusCreated)
219 }))
220 defer srv.Close()
221
222 path := test.CreateTempFileBinary(t, make([]byte, size))
223
224 definition := `
225servers:
226- url: https://cloud.uipath.com/{organization}/{tenant}/orchestrator_
227 description: The production url
228 variables:
229 organization:
230 description: The organization name (or id)
231 default: my-org
232 tenant:
233 description: The tenant name (or id)
234 default: my-tenant
235`
236
237 context := test.NewContextBuilder().
238 WithDefinition("orchestrator", definition).
239 WithCommandPlugin(NewUploadCommand()).
240 WithResponse(http.StatusOK, `{"Uri":"`+srv.URL+`"}`).
241 Build()
242
243 result := test.RunCli([]string{"orchestrator", "buckets", "upload", "--organization", "myorg", "--tenant", "mytenant", "--folder-id", "1", "--key", "2", "--path", "file.txt", "--file", path}, context)
244
245 if result.Error != nil {
246 t.Errorf("Expected no error, but got: %v", result.Error)
247 }
248}
249
250func TestUploadWithDebugOutput(t *testing.T) {
251 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 10

CreateTempFileBinaryFunction · 0.92
NewContextBuilderFunction · 0.92
RunCliFunction · 0.92
NewUploadCommandFunction · 0.85
CloseMethod · 0.80
WithResponseMethod · 0.80
WithCommandPluginMethod · 0.80
WithDefinitionMethod · 0.80
WriteMethod · 0.65
BuildMethod · 0.45

Tested by

no test coverage detected