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

313 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

Can be done in several lines.

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