Skip to content

Commit 9c1afa7

Browse files
committed
Re-add clean-up for gRPC tests
1 parent da86834 commit 9c1afa7

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

internal/server/machine_create_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ var _ = Describe("CreateMachine", func() {
9393
})
9494
Expect(err).NotTo(HaveOccurred())
9595
Expect(createResp).NotTo(BeNil())
96-
DeferCleanup(func() {
97-
err := machineStore.Delete(ctx, createResp.Machine.Metadata.Id)
98-
Expect(err).NotTo(HaveOccurred())
99-
})
96+
DeferCleanup(cleanupMachine(createResp.Machine.Metadata.Id))
10097

10198
By("ensuring the correct creation response")
10299
Expect(createResp).Should(SatisfyAll(

internal/server/server_suite_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,17 @@ func isSocketAvailable(socketPath string) error {
217217
}
218218
return fmt.Errorf("socket %s is not available", socketPath)
219219
}
220+
221+
func cleanupMachine(machineID string) func(SpecContext) {
222+
return func(ctx SpecContext) {
223+
By(fmt.Sprintf("Cleaning up machine ID=%s", machineID))
224+
Eventually(func(g Gomega) error {
225+
err := machineStore.Delete(context.Background(), machineID)
226+
GinkgoWriter.Printf("Deleting machine ID=%s: err=%v\n", machineID, err)
227+
if success, _ := MatchError(ContainSubstring("no such file or directory")).Match(err); success {
228+
return nil
229+
}
230+
return err
231+
}).Should(Succeed())
232+
}
233+
}

0 commit comments

Comments
 (0)