Skip to content

Commit 82c6974

Browse files
committed
refactor: migrate Ginkgo v1 AfterEach cleanup to v2 DeferCleanup
Replace all AfterEach cleanup blocks with DeferCleanup calls co-located in BeforeEach/JustBeforeEach, following Ginkgo v2 idioms. Bare AfterEach at Describe-level are replaced with direct DeferCleanup calls in the Describe body.
1 parent 9486fd4 commit 82c6974

2 files changed

Lines changed: 9 additions & 18 deletions

File tree

src/staticfile/finalize/finalize_test.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ var _ = Describe("Compile", func() {
4848

4949
mockCtrl = gomock.NewController(GinkgoT())
5050
mockYaml = NewMockYAML(mockCtrl)
51+
DeferCleanup(func() {
52+
err = os.RemoveAll(buildDir)
53+
Expect(err).To(BeNil())
54+
55+
err = os.RemoveAll(depDir)
56+
Expect(err).To(BeNil())
57+
})
5158
})
5259

5360
JustBeforeEach(func() {
@@ -60,16 +67,6 @@ var _ = Describe("Compile", func() {
6067
}
6168
})
6269

63-
AfterEach(func() {
64-
mockCtrl.Finish()
65-
66-
err = os.RemoveAll(buildDir)
67-
Expect(err).To(BeNil())
68-
69-
err = os.RemoveAll(depDir)
70-
Expect(err).To(BeNil())
71-
})
72-
7370
Describe("WriteStartupFiles", func() {
7471
It("writes staticfile.sh to the profile.d directory", func() {
7572
err = finalizer.WriteStartupFiles()
@@ -909,7 +906,7 @@ var _ = Describe("Compile", func() {
909906
Expect(err).To(BeNil())
910907
})
911908

912-
AfterEach(func() {
909+
DeferCleanup(func() {
913910
err = os.RemoveAll(appRootDir)
914911
Expect(err).To(BeNil())
915912
})

src/staticfile/supply/supply_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var _ = Describe("Supply", func() {
4848
mockCtrl = gomock.NewController(GinkgoT())
4949
mockManifest = NewMockManifest(mockCtrl)
5050
mockInstaller = NewMockInstaller(mockCtrl)
51+
DeferCleanup(os.RemoveAll, depsDir)
5152
})
5253

5354
JustBeforeEach(func() {
@@ -62,13 +63,6 @@ var _ = Describe("Supply", func() {
6263
}
6364
})
6465

65-
AfterEach(func() {
66-
mockCtrl.Finish()
67-
68-
err = os.RemoveAll(depsDir)
69-
Expect(err).To(BeNil())
70-
})
71-
7266
Describe("InstallNginx", func() {
7367
BeforeEach(func() {
7468
dep := libbuildpack.Dependency{Name: "nginx", Version: "99.99"}

0 commit comments

Comments
 (0)