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

Function TestS3RunNotExitOnError

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

Source from the content-addressed store, hash-verified

353}
354
355func TestS3RunNotExitOnError(t *testing.T) {
356 defer testutil.DisableLogging()()
357
358 tmpDir, fnames := prepareUploadS3TestFolder(t, 1)
359 fname := fnames[0]
360
361 stagingDir := t.TempDir()
362 defer os.RemoveAll(stagingDir)
363
364 cfg := baker.UploadParams{
365 ComponentParams: baker.ComponentParams{
366 DecodedConfig: &S3Config{
367 SourceBasePath: stagingDir,
368 StagingPath: tmpDir,
369 Bucket: "my-bucket",
370 Concurrency: 5,
371 Retries: 3,
372 ExitOnError: false,
373 },
374 },
375 }
376 iu, err := NewS3(cfg)
377 if err != nil {
378 t.Fatalf("NewS3Upload(%+v) = %q", cfg, err)
379 }
380 s, _, _ := mockS3Service(true)
381 u := iu.(*S3)
382 u.uploader = s3manager.NewUploaderWithClient(s)
383
384 ch := make(chan string)
385 go func() {
386 ch <- fname
387 close(ch)
388 }()
389
390 err = u.Run(ch)
391 if err != nil {
392 t.Fatal(err)
393 }
394
395 if int(u.totalerr) > 1*u.Cfg.Retries {
396 t.Fatalf("totalerr: want: <=%d, got: %d", 1*u.Cfg.Retries, int(u.totalerr))
397 }
398
399 if int(u.totaln) != 1 {
400 t.Fatalf("totaln: want: %d, got: %d", 1, int(u.totaln))
401 }
402}
403
404func TestS3_move(t *testing.T) {
405 srcDir := t.TempDir()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected