Skip to content

Commit b1d02e2

Browse files
committed
Cleanup sqlserver images after tests run
1 parent 49cac86 commit b1d02e2

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

database/sqlserver/sqlserver_test.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ func SkipIfUnsupportedArch(t *testing.T, c dktest.ContainerInfo) {
9696
}
9797

9898
func Test(t *testing.T) {
99+
t.Run("test", test)
100+
t.Run("testMigrate", testMigrate)
101+
t.Run("testMultiStatement", testMultiStatement)
102+
t.Run("testErrorParsing", testErrorParsing)
103+
t.Run("testLockWorks", testLockWorks)
104+
t.Run("testMsiTrue", testMsiTrue)
105+
t.Run("testOpenWithPasswordAndMSI", testOpenWithPasswordAndMSI)
106+
t.Run("testMsiFalse", testMsiFalse)
107+
108+
t.Cleanup(func() {
109+
for _, spec := range specs {
110+
t.Log("Cleaning up ", spec.ImageName)
111+
if err := spec.Cleanup(); err != nil {
112+
t.Error("Error removing ", spec.ImageName, "error:", err)
113+
}
114+
}
115+
})
116+
}
117+
118+
func test(t *testing.T) {
99119
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
100120
SkipIfUnsupportedArch(t, c)
101121
ip, port, err := c.Port(defaultPort)
@@ -120,7 +140,7 @@ func Test(t *testing.T) {
120140
})
121141
}
122142

123-
func TestMigrate(t *testing.T) {
143+
func testMigrate(t *testing.T) {
124144
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
125145
SkipIfUnsupportedArch(t, c)
126146
ip, port, err := c.Port(defaultPort)
@@ -149,7 +169,7 @@ func TestMigrate(t *testing.T) {
149169
})
150170
}
151171

152-
func TestMultiStatement(t *testing.T) {
172+
func testMultiStatement(t *testing.T) {
153173
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
154174
SkipIfUnsupportedArch(t, c)
155175
ip, port, err := c.Port(defaultPort)
@@ -183,7 +203,7 @@ func TestMultiStatement(t *testing.T) {
183203
})
184204
}
185205

186-
func TestErrorParsing(t *testing.T) {
206+
func testErrorParsing(t *testing.T) {
187207
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
188208
SkipIfUnsupportedArch(t, c)
189209
ip, port, err := c.Port(defaultPort)
@@ -215,7 +235,7 @@ func TestErrorParsing(t *testing.T) {
215235
})
216236
}
217237

218-
func TestLockWorks(t *testing.T) {
238+
func testLockWorks(t *testing.T) {
219239
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
220240
SkipIfUnsupportedArch(t, c)
221241
ip, port, err := c.Port(defaultPort)
@@ -254,7 +274,7 @@ func TestLockWorks(t *testing.T) {
254274
})
255275
}
256276

257-
func TestMsiTrue(t *testing.T) {
277+
func testMsiTrue(t *testing.T) {
258278
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
259279
SkipIfUnsupportedArch(t, c)
260280
ip, port, err := c.Port(defaultPort)
@@ -271,7 +291,7 @@ func TestMsiTrue(t *testing.T) {
271291
})
272292
}
273293

274-
func TestOpenWithPasswordAndMSI(t *testing.T) {
294+
func testOpenWithPasswordAndMSI(t *testing.T) {
275295
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
276296
SkipIfUnsupportedArch(t, c)
277297
ip, port, err := c.Port(defaultPort)
@@ -303,7 +323,7 @@ func TestOpenWithPasswordAndMSI(t *testing.T) {
303323
})
304324
}
305325

306-
func TestMsiFalse(t *testing.T) {
326+
func testMsiFalse(t *testing.T) {
307327
dktesting.ParallelTest(t, specs, func(t *testing.T, c dktest.ContainerInfo) {
308328
SkipIfUnsupportedArch(t, c)
309329
ip, port, err := c.Port(defaultPort)

0 commit comments

Comments
 (0)