Skip to content

Commit 4f6ba82

Browse files
committed
Ensure close in content test
Signed-off-by: Michael Crosby <[email protected]>
1 parent faa5f55 commit 4f6ba82

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

content/testsuite/testsuite.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ func checkRefNotAvailable(ctx context.Context, t *testing.T, cs content.Store, r
338338

339339
w, err := cs.Writer(ctx, content.WithRef(ref))
340340
if err == nil {
341-
w.Close()
341+
defer w.Close()
342342
t.Fatal("writer created with ref, expected to be in use")
343343
}
344344
if !errdefs.IsUnavailable(err) {
@@ -402,6 +402,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
402402
}
403403
t.Fatalf("Unexpected error: %+v", err)
404404
}
405+
w.Close()
405406

406407
w, err = cs.Writer(ctx, content.WithRef(ref))
407408
if err != nil {
@@ -425,6 +426,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
425426
t.Errorf("Unexpected error: %+v", err)
426427
}
427428

429+
w.Close()
428430
w, err = cs.Writer(ctx, content.WithRef(ref))
429431
if err != nil {
430432
t.Fatal(err)
@@ -440,6 +442,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
440442
t.Errorf("Unexpected error: %+v", err)
441443
}
442444

445+
w.Close()
443446
w, err = cs.Writer(ctx, content.WithRef(ref))
444447
if err != nil {
445448
t.Fatal(err)
@@ -455,6 +458,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
455458
t.Fatalf("Failed to commit: %+v", err)
456459
}
457460

461+
w.Close()
458462
// Create another writer with same reference
459463
w, err = cs.Writer(ctx, content.WithRef(ref))
460464
if err != nil {
@@ -481,6 +485,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
481485
t.Fatalf("Unexpected error: %+v", err)
482486
}
483487

488+
w.Close()
484489
w, err = cs.Writer(ctx, content.WithRef(ref))
485490
if err != nil {
486491
t.Fatal(err)

0 commit comments

Comments
 (0)