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

Function TestS3RunExitOnError

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

Source from the content-addressed store, hash-verified

307}
308
309func TestS3RunExitOnError(t *testing.T) {
310 defer testutil.DisableLogging()()
311
312 tmpDir, fnames := prepareUploadS3TestFolder(t, 1)
313 fname := fnames[0]
314
315 stagingDir := t.TempDir()
316
317 cfg := baker.UploadParams{
318 ComponentParams: baker.ComponentParams{
319 DecodedConfig: &S3Config{
320 SourceBasePath: stagingDir,
321 StagingPath: tmpDir,
322 Bucket: "my-bucket",
323 ExitOnError: true,
324 },
325 },
326 }
327 iu, err := NewS3(cfg)
328 if err != nil {
329 t.Fatalf("NewS3Upload(%+v) = %q", cfg, err)
330 }
331 s, _, _ := mockS3Service(true)
332 u := iu.(*S3)
333 u.uploader = s3manager.NewUploaderWithClient(s)
334
335 ch := make(chan string)
336 go func() {
337 ch <- fname
338 close(ch)
339 }()
340
341 err = u.Run(ch)
342 if err != nil {
343 t.Fatal(err)
344 }
345
346 if int(u.totalerr) != 1 {
347 t.Fatalf("totalerr: want: %d, got: %d", 1, int(u.totalerr))
348 }
349
350 if int(u.totaln) != 1 {
351 t.Fatalf("totaln: want: %d, got: %d", 1, int(u.totaln))
352 }
353}
354
355func TestS3RunNotExitOnError(t *testing.T) {
356 defer testutil.DisableLogging()()

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