Skip to content

Commit 4037c9c

Browse files
authored
Merge pull request #1175 from buildpacks/polish/pr-1159
Polish: PR #1159
2 parents d14662e + 3fac0b4 commit 4037c9c

5 files changed

Lines changed: 36 additions & 31 deletions

File tree

build_test.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
132132
})
133133

134134
it.After(func() {
135-
defaultBuilderImage.Cleanup()
136-
fakeDefaultRunImage.Cleanup()
137-
fakeMirror1.Cleanup()
138-
fakeMirror2.Cleanup()
135+
h.AssertNilE(t, defaultBuilderImage.Cleanup())
136+
h.AssertNilE(t, fakeDefaultRunImage.Cleanup())
137+
h.AssertNilE(t, fakeMirror1.Cleanup())
138+
h.AssertNilE(t, fakeMirror2.Cleanup())
139139
os.RemoveAll(tmpDir)
140-
fakeLifecycleImage.Cleanup()
140+
h.AssertNilE(t, fakeLifecycleImage.Cleanup())
141141
})
142142

143143
when("#Build", func() {
@@ -226,9 +226,9 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
226226
})
227227

228228
it.After(func() {
229-
remoteRunImage.Cleanup()
230-
builderWithoutLifecycleImageOrCreator.Cleanup()
231-
h.AssertNil(t, builtImage.Cleanup())
229+
h.AssertNilE(t, remoteRunImage.Cleanup())
230+
h.AssertNilE(t, builderWithoutLifecycleImageOrCreator.Cleanup())
231+
h.AssertNilE(t, builtImage.Cleanup())
232232
})
233233

234234
it("only prints app name and sha", func() {
@@ -254,7 +254,7 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
254254
})
255255

256256
it.After(func() {
257-
builtImage.Cleanup()
257+
h.AssertNilE(t, builtImage.Cleanup())
258258
})
259259

260260
it("only prints app name and sha", func() {
@@ -462,8 +462,8 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
462462
})
463463

464464
it.After(func() {
465-
customBuilderImage.Cleanup()
466-
fakeRunImage.Cleanup()
465+
h.AssertNilE(t, customBuilderImage.Cleanup())
466+
h.AssertNilE(t, fakeRunImage.Cleanup())
467467
})
468468

469469
it("it uses the provided builder", func() {
@@ -489,7 +489,7 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
489489
})
490490

491491
it.After(func() {
492-
fakeRunImage.Cleanup()
492+
h.AssertNilE(t, fakeRunImage.Cleanup())
493493
})
494494

495495
when("run image stack matches the builder stack", func() {
@@ -588,8 +588,8 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
588588
})
589589

590590
it.After(func() {
591-
fakeLocalMirror.Cleanup()
592-
fakeLocalMirror1.Cleanup()
591+
h.AssertNilE(t, fakeLocalMirror.Cleanup())
592+
h.AssertNilE(t, fakeLocalMirror1.Cleanup())
593593
})
594594

595595
when("Publish is true", func() {
@@ -1147,7 +1147,7 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
11471147
})
11481148

11491149
it.After(func() {
1150-
h.AssertNil(t, os.Remove(buildpackTgz))
1150+
h.AssertNilE(t, os.Remove(buildpackTgz))
11511151
})
11521152

11531153
it("buildpacks are added to ephemeral builder", func() {
@@ -1331,8 +1331,7 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
13311331

13321332
it.After(func() {
13331333
os.Unsetenv("PACK_HOME")
1334-
err := os.RemoveAll(tmpDir)
1335-
h.AssertNil(t, err)
1334+
h.AssertNil(t, os.RemoveAll(tmpDir))
13361335
})
13371336

13381337
it("all buildpacks are added to ephemeral builder", func() {
@@ -1644,9 +1643,9 @@ func testBuild(t *testing.T, when spec.G, it spec.S) {
16441643
})
16451644

16461645
it.After(func() {
1647-
h.AssertNil(t, os.Unsetenv("HTTP_PROXY"))
1648-
h.AssertNil(t, os.Unsetenv("HTTPS_PROXY"))
1649-
h.AssertNil(t, os.Unsetenv("NO_PROXY"))
1646+
h.AssertNilE(t, os.Unsetenv("HTTP_PROXY"))
1647+
h.AssertNilE(t, os.Unsetenv("HTTPS_PROXY"))
1648+
h.AssertNilE(t, os.Unsetenv("NO_PROXY"))
16501649
})
16511650

16521651
it("defaults to the *_PROXY environment variables", func() {

internal/build/container_ops_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,18 @@ func cleanupContainer(ctx context.Context, ctrID string) {
352352
}
353353

354354
// remove container
355-
ctrClient.ContainerRemove(ctx, ctrID, types.ContainerRemoveOptions{})
355+
err = ctrClient.ContainerRemove(ctx, ctrID, types.ContainerRemoveOptions{})
356+
if err != nil {
357+
return
358+
}
356359

357360
// remove volumes
358361
for _, m := range inspect.Mounts {
359362
if m.Type == mount.TypeVolume {
360-
ctrClient.VolumeRemove(ctx, m.Name, true)
363+
err = ctrClient.VolumeRemove(ctx, m.Name, true)
364+
if err != nil {
365+
return
366+
}
361367
}
362368
}
363369
}

internal/build/phase_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func testPhase(t *testing.T, when spec.G, it spec.S) {
9494
})
9595

9696
it.After(func() {
97-
h.AssertNil(t, lifecycleExec.Cleanup())
97+
h.AssertNilE(t, lifecycleExec.Cleanup())
9898
})
9999

100100
when("Phase", func() {
@@ -167,7 +167,7 @@ func testPhase(t *testing.T, when spec.G, it spec.S) {
167167
configProvider = build.NewPhaseConfigProvider(phaseName, lifecycleExec, build.WithArgs("read", "/workspace/fake-app-file"))
168168
readPhase2 := phaseFactory.New(configProvider)
169169
err := readPhase2.Run(context.TODO())
170-
readPhase2.Cleanup()
170+
h.AssertNil(t, readPhase2.Cleanup())
171171
h.AssertNotNil(t, err)
172172
h.AssertContains(t, outBuf.String(), "failed to read file")
173173
})
@@ -212,7 +212,7 @@ func testPhase(t *testing.T, when spec.G, it spec.S) {
212212
})
213213

214214
it.After(func() {
215-
h.AssertNil(t, os.RemoveAll(tmpFakeAppDir))
215+
h.AssertNilE(t, os.RemoveAll(tmpFakeAppDir))
216216
})
217217

218218
it("returns an error", func() {
@@ -335,7 +335,7 @@ func testPhase(t *testing.T, when spec.G, it spec.S) {
335335

336336
when("#WithBinds", func() {
337337
it.After(func() {
338-
docker.VolumeRemove(context.TODO(), "some-volume", true)
338+
h.AssertNilE(t, docker.VolumeRemove(context.TODO(), "some-volume", true))
339339
})
340340

341341
it("mounts volumes inside container", func() {
@@ -364,7 +364,7 @@ func testPhase(t *testing.T, when spec.G, it spec.S) {
364364
if registry != nil {
365365
registry.StopRegistry(t)
366366
}
367-
h.AssertNil(t, os.Unsetenv("DOCKER_CONFIG"))
367+
h.AssertNilE(t, os.Unsetenv("DOCKER_CONFIG"))
368368
})
369369

370370
it("provides auth for registry in the container", func() {

internal/builder/builder_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
136136
})
137137

138138
it.After(func() {
139-
baseImage.Cleanup()
139+
h.AssertNilE(t, baseImage.Cleanup())
140140
mockController.Finish()
141141
})
142142

@@ -266,7 +266,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
266266
})
267267

268268
it.After(func() {
269-
baseImage.Cleanup()
269+
h.AssertNilE(t, baseImage.Cleanup())
270270
})
271271

272272
when("#Save", func() {
@@ -405,7 +405,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) {
405405
h.AssertNil(t, err)
406406

407407
h.AssertNil(t, baseImage.AddLayer(layerFile))
408-
baseImage.Save()
408+
h.AssertNil(t, baseImage.Save())
409409

410410
h.AssertNil(t, subject.Save(logger, builder.CreatorMetadata{}))
411411
h.AssertEq(t, baseImage.IsSaved(), true)

internal/buildpackage/builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func testPackageBuilder(t *testing.T, when spec.G, it spec.S) {
5959
})
6060

6161
it.After(func() {
62-
h.AssertNil(t, os.RemoveAll(tmpDir))
62+
h.AssertNilE(t, os.RemoveAll(tmpDir))
6363
mockController.Finish()
6464
})
6565

0 commit comments

Comments
 (0)