@@ -34,21 +34,49 @@ import (
34
34
"github.com/containerd/containerd/snapshots/testsuite"
35
35
)
36
36
37
- func newSnapshotter (ctx context.Context , root string ) (snapshots.Snapshotter , func () error , error ) {
38
- snapshotter , err := NewSnapshotter (root )
39
- if err != nil {
40
- return nil , nil , err
41
- }
37
+ func newSnapshotterWithOpts (opts ... Opt ) testsuite.SnapshotterFunc {
38
+ return func (ctx context.Context , root string ) (snapshots.Snapshotter , func () error , error ) {
39
+ snapshotter , err := NewSnapshotter (root , opts ... )
40
+ if err != nil {
41
+ return nil , nil , err
42
+ }
42
43
43
- return snapshotter , func () error { return snapshotter .Close () }, nil
44
+ return snapshotter , func () error { return snapshotter .Close () }, nil
45
+ }
44
46
}
45
47
46
48
func TestOverlay (t * testing.T ) {
47
49
testutil .RequiresRoot (t )
48
- testsuite .SnapshotterSuite (t , "Overlay" , newSnapshotter )
50
+ optTestCases := map [string ][]Opt {
51
+ "no opt" : nil ,
52
+ // default in init()
53
+ "AsynchronousRemove" : {AsynchronousRemove },
54
+ }
55
+
56
+ for optsName , opts := range optTestCases {
57
+ t .Run (optsName , func (t * testing.T ) {
58
+ newSnapshotter := newSnapshotterWithOpts (opts ... )
59
+ testsuite .SnapshotterSuite (t , "Overlay" , newSnapshotter )
60
+ t .Run ("TestOverlayMounts" , func (t * testing.T ) {
61
+ testOverlayMounts (t , newSnapshotter )
62
+ })
63
+ t .Run ("TestOverlayCommit" , func (t * testing.T ) {
64
+ testOverlayCommit (t , newSnapshotter )
65
+ })
66
+ t .Run ("TestOverlayOverlayMount" , func (t * testing.T ) {
67
+ testOverlayOverlayMount (t , newSnapshotter )
68
+ })
69
+ t .Run ("TestOverlayOverlayRead" , func (t * testing.T ) {
70
+ testOverlayOverlayRead (t , newSnapshotter )
71
+ })
72
+ t .Run ("TestOverlayView" , func (t * testing.T ) {
73
+ testOverlayView (t , newSnapshotter )
74
+ })
75
+ })
76
+ }
49
77
}
50
78
51
- func TestOverlayMounts (t * testing.T ) {
79
+ func testOverlayMounts (t * testing.T , newSnapshotter testsuite. SnapshotterFunc ) {
52
80
ctx := context .TODO ()
53
81
root , err := ioutil .TempDir ("" , "overlay" )
54
82
if err != nil {
@@ -82,7 +110,7 @@ func TestOverlayMounts(t *testing.T) {
82
110
}
83
111
}
84
112
85
- func TestOverlayCommit (t * testing.T ) {
113
+ func testOverlayCommit (t * testing.T , newSnapshotter testsuite. SnapshotterFunc ) {
86
114
ctx := context .TODO ()
87
115
root , err := ioutil .TempDir ("" , "overlay" )
88
116
if err != nil {
@@ -107,7 +135,7 @@ func TestOverlayCommit(t *testing.T) {
107
135
}
108
136
}
109
137
110
- func TestOverlayOverlayMount (t * testing.T ) {
138
+ func testOverlayOverlayMount (t * testing.T , newSnapshotter testsuite. SnapshotterFunc ) {
111
139
ctx := context .TODO ()
112
140
root , err := ioutil .TempDir ("" , "overlay" )
113
141
if err != nil {
@@ -190,7 +218,7 @@ func getParents(ctx context.Context, sn snapshots.Snapshotter, root, key string)
190
218
return parents
191
219
}
192
220
193
- func TestOverlayOverlayRead (t * testing.T ) {
221
+ func testOverlayOverlayRead (t * testing.T , newSnapshotter testsuite. SnapshotterFunc ) {
194
222
testutil .RequiresRoot (t )
195
223
ctx := context .TODO ()
196
224
root , err := ioutil .TempDir ("" , "overlay" )
@@ -234,7 +262,7 @@ func TestOverlayOverlayRead(t *testing.T) {
234
262
}
235
263
}
236
264
237
- func TestOverlayView (t * testing.T ) {
265
+ func testOverlayView (t * testing.T , newSnapshotter testsuite. SnapshotterFunc ) {
238
266
ctx := context .TODO ()
239
267
root , err := ioutil .TempDir ("" , "overlay" )
240
268
if err != nil {
0 commit comments