(t *testing.T)
| 207 | } |
| 208 | |
| 209 | func 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 := ` |
| 225 | servers: |
| 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 | |
| 250 | func TestUploadWithDebugOutput(t *testing.T) { |
| 251 | srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected