Ensure close in content test

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2019-06-04 19:02:27 +00:00
parent faa5f55189
commit 4f6ba8286d

View File

@ -338,7 +338,7 @@ func checkRefNotAvailable(ctx context.Context, t *testing.T, cs content.Store, r
w, err := cs.Writer(ctx, content.WithRef(ref))
if err == nil {
w.Close()
defer w.Close()
t.Fatal("writer created with ref, expected to be in use")
}
if !errdefs.IsUnavailable(err) {
@ -402,6 +402,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
}
t.Fatalf("Unexpected error: %+v", err)
}
w.Close()
w, err = cs.Writer(ctx, content.WithRef(ref))
if err != nil {
@ -425,6 +426,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
t.Errorf("Unexpected error: %+v", err)
}
w.Close()
w, err = cs.Writer(ctx, content.WithRef(ref))
if err != nil {
t.Fatal(err)
@ -440,6 +442,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
t.Errorf("Unexpected error: %+v", err)
}
w.Close()
w, err = cs.Writer(ctx, content.WithRef(ref))
if err != nil {
t.Fatal(err)
@ -455,6 +458,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
t.Fatalf("Failed to commit: %+v", err)
}
w.Close()
// Create another writer with same reference
w, err = cs.Writer(ctx, content.WithRef(ref))
if err != nil {
@ -481,6 +485,7 @@ func checkCommitErrorState(ctx context.Context, t *testing.T, cs content.Store)
t.Fatalf("Unexpected error: %+v", err)
}
w.Close()
w, err = cs.Writer(ctx, content.WithRef(ref))
if err != nil {
t.Fatal(err)