Skip to content

Commit

Permalink
Fix tests for cleanstack
Browse files Browse the repository at this point in the history
Is no longer provided by enki but by the sdk, so tests do not need to be
here anymore

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
  • Loading branch information
Itxaka committed Jul 27, 2023
1 parent 422bfa0 commit 758e97a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 75 deletions.
74 changes: 0 additions & 74 deletions tools-image/enki/pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,78 +291,4 @@ var _ = Describe("Utils", Label("utils"), func() {
Expect(err).To(HaveOccurred())
})
})
Describe("CleanStack", Label("CleanStack"), func() {
var cleaner *utils.CleanStack
BeforeEach(func() {
cleaner = utils.NewCleanStack()
})
It("Adds a callback to the stack and pops it", func() {
var flag bool
callback := func() error {
flag = true
return nil
}
Expect(cleaner.Pop()).To(BeNil())
cleaner.Push(callback)
poppedJob := cleaner.Pop()
Expect(poppedJob).NotTo(BeNil())
poppedJob()
Expect(flag).To(BeTrue())
})
It("On Cleanup runs callback stack in reverse order", func() {
result := ""
callback1 := func() error {
result = result + "one "
return nil
}
callback2 := func() error {
result = result + "two "
return nil
}
callback3 := func() error {
result = result + "three "
return nil
}
cleaner.Push(callback1)
cleaner.Push(callback2)
cleaner.Push(callback3)
cleaner.Cleanup(nil)
Expect(result).To(Equal("three two one "))
})
It("On Cleanup keeps former error and all callbacks are executed", func() {
err := errors.New("Former error")
count := 0
callback := func() error {
count++
if count == 2 {
return errors.New("Cleanup Error")
}
return nil
}
cleaner.Push(callback)
cleaner.Push(callback)
cleaner.Push(callback)
err = cleaner.Cleanup(err)
Expect(count).To(Equal(3))
Expect(err.Error()).To(ContainSubstring("Former error"))
})
It("On Cleanup error reports first error and all callbacks are executed", func() {
var err error
count := 0
callback := func() error {
count++
if count >= 2 {
return errors.New(fmt.Sprintf("Cleanup error %d", count))
}
return nil
}
cleaner.Push(callback)
cleaner.Push(callback)
cleaner.Push(callback)
err = cleaner.Cleanup(err)
Expect(count).To(Equal(3))
Expect(err.Error()).To(ContainSubstring("Cleanup error 2"))
Expect(err.Error()).To(ContainSubstring("Cleanup error 3"))
})
})
})
2 changes: 1 addition & 1 deletion tools-image/luet-amd64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ repositories:
priority: 2
urls:
- "quay.io/kairos/packages"
reference: 20230718103103-repository.yaml
reference: 20230718103103-repository.yaml

0 comments on commit 758e97a

Please sign in to comment.