Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Add aftereach func to remove left over files
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitsakala committed Apr 30, 2020
1 parent 0d9d8d1 commit 680d025
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/kube/controllers/quarksjob/output_persistor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,10 @@ var _ = Describe("OutputPersistor", func() {
})

Context("when the output file is not json valid", func() {

BeforeEach(func() {
// Create faulty output file
dataJSON = []byte("{\"hello\"= \"world\"}")
err := ioutil.WriteFile(filepath.Join(tmpDir, "busybox", "faultyoutput.json"), dataJSON, 0755)
faultydataJSON := []byte("{\"hello\"= \"world\"}")
err := ioutil.WriteFile(filepath.Join(tmpDir, "busybox", "faultyoutput.json"), faultydataJSON, 0755)
Expect(err).NotTo(HaveOccurred())

qJob.Spec.Output.OutputMap = qjv1a1.OutputMap{
Expand Down Expand Up @@ -211,6 +210,10 @@ var _ = Describe("OutputPersistor", func() {
})
})
})

AfterEach(func() {
Expect(os.RemoveAll(tmpDir)).ToNot(HaveOccurred())
})
})

Context("when persisting multiple outputs", func() {
Expand Down Expand Up @@ -326,6 +329,9 @@ var _ = Describe("OutputPersistor", func() {

Context("With a failed Job", func() {
BeforeEach(func() {
err := ioutil.WriteFile(filepath.Join(tmpDir, "busybox", "output.json"), dataJSON, 0755)
Expect(err).NotTo(HaveOccurred())

pod.Status.ContainerStatuses = []corev1.ContainerStatus{
{
Name: "busybox",
Expand Down Expand Up @@ -355,6 +361,10 @@ var _ = Describe("OutputPersistor", func() {
Expect(err).NotTo(HaveOccurred())
})
})

AfterEach(func() {
Expect(os.RemoveAll(tmpDir)).ToNot(HaveOccurred())
})
})
})
})

0 comments on commit 680d025

Please sign in to comment.