Merge pull request #1842 from dmcgowan/fix-snapshot-close-twice

Fix close twice test to retain snapshots
This commit is contained in:
Derek McGowan 2017-11-30 14:57:48 -08:00 committed by GitHub
commit 763d29f4c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math/rand"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -807,14 +808,17 @@ func checkFileFromLowerLayer(ctx context.Context, t *testing.T, snapshotter snap
} }
func closeTwice(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { func closeTwice(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
n := fmt.Sprintf("closeTwice-%d", rand.Int())
prepare := fmt.Sprintf("%s-prepare", n)
// do some dummy ops to modify the snapshotter internal state // do some dummy ops to modify the snapshotter internal state
if _, err := snapshotter.Prepare(ctx, "dummy", ""); err != nil { if _, err := snapshotter.Prepare(ctx, prepare, "", opt); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := snapshotter.Commit(ctx, "dummy-1", "dummy"); err != nil { if err := snapshotter.Commit(ctx, n, prepare, opt); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := snapshotter.Remove(ctx, "dummy-1"); err != nil { if err := snapshotter.Remove(ctx, n); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if err := snapshotter.Close(); err != nil { if err := snapshotter.Close(); err != nil {