MCPcopy Create free account
hub / github.com/AdRoll/baker / TestS3_uploadDirectoryError

Function TestS3_uploadDirectoryError

upload/s3_test.go:237–307  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

235}
236
237func TestS3_uploadDirectoryError(t *testing.T) {
238 defer testutil.DisableLogging()()
239
240 numFiles := 10
241 srcDir, _ := prepareUploadS3TestFolder(t, numFiles)
242
243 t.Run("ExitOnError: false", func(t *testing.T) {
244 cfg := baker.UploadParams{
245 ComponentParams: baker.ComponentParams{
246 DecodedConfig: &S3Config{
247 SourceBasePath: srcDir,
248 StagingPath: srcDir,
249 Bucket: "my-bucket",
250 Concurrency: 5,
251 Retries: 3,
252 ExitOnError: false,
253 },
254 },
255 }
256 iu, err := NewS3(cfg)
257 if err != nil {
258 t.Fatalf("NewS3Upload(%+v) = %q", cfg, err)
259 }
260 s, _, _ := mockS3Service(true)
261 u := iu.(*S3)
262 u.uploader = s3manager.NewUploaderWithClient(s)
263
264 if err := u.uploadDirectory(); err != nil {
265 log.Fatal(err)
266 }
267 if int(u.totaln) != 0 {
268 t.Fatalf("uploaded: want: %d, got: %d", 0, int(u.totaln))
269 }
270
271 if int(u.totalerr) != numFiles*u.Cfg.Retries {
272 t.Fatalf("errors: want: %d, got: %d", numFiles*u.Cfg.Retries, int(u.totalerr))
273 }
274 })
275
276 t.Run("ExitOnError: true", func(t *testing.T) {
277 cfg := baker.UploadParams{
278 ComponentParams: baker.ComponentParams{
279 DecodedConfig: &S3Config{
280 SourceBasePath: srcDir,
281 StagingPath: srcDir,
282 Bucket: "my-bucket",
283 Concurrency: 5,
284 Retries: 3,
285 ExitOnError: true,
286 },
287 },
288 }
289 iu, err := NewS3(cfg)
290 if err != nil {
291 t.Fatalf("NewS3Upload(%+v) = %q", cfg, err)
292 }
293 s, _, _ := mockS3Service(true)
294 u := iu.(*S3)

Callers

nothing calls this directly

Calls 6

DisableLoggingFunction · 0.92
NewS3Function · 0.85
uploadDirectoryMethod · 0.80
mockS3ServiceFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected