Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't panic on Eventually(nil), fixing #555 #567

Merged
merged 1 commit into from Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/async_assertion.go
Expand Up @@ -40,7 +40,7 @@ func NewAsyncAssertion(asyncType AsyncAssertionType, actualInput interface{}, g
}

switch actualType := reflect.TypeOf(actualInput); {
case actualType.Kind() != reflect.Func:
case actualInput == nil || actualType.Kind() != reflect.Func:
out.actualValue = actualInput
case actualType.NumIn() == 0 && actualType.NumOut() > 0:
out.actualIsFunc = true
Expand Down
18 changes: 18 additions & 0 deletions internal/async_assertion_test.go
Expand Up @@ -742,4 +742,22 @@ var _ = Describe("Asynchronous Assertions", func() {

})

Context("eventual nil-ism", func() { // issue #555

It("doesn't panic on nil actual", func() {
ig := NewInstrumentedGomega()
Expect(func() {
ig.G.Eventually(nil).Should(BeNil())
}).NotTo(Panic())
})

It("doesn't panic on function returning nil error", func() {
ig := NewInstrumentedGomega()
Expect(func() {
ig.G.Eventually(func() error { return nil }).Should(BeNil())
}).NotTo(Panic())
})

})

})