Can Gomega support verification of multiple return values of different types where the last one is not `error`?

Issue

For instance:
If I have a wrapper for https://pkg.go.dev/sync#Map.Load:
with the same method signature:

func Load(key string) (value interface{}, ok bool)

in Can Gomega's Equal() handle multiple values ? similar question was asked and the response is to put the return values into single data structure. If that is the case, what if I don’t want to adapt the (production) code based on this limitation of the unit test framework?

Solution

Can be done in several lines.

        value, ok := m.Load(key)
        Expect(value).NotTo(BeNil())
        Expect(ok).To(BeTrue())

Answered By – user892960

Answer Checked By – Mary Flores (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.