Home > Net >  Can Gomega support verification of multiple return values of different types where the last one is n
Can Gomega support verification of multiple return values of different types where the last one is n

Time:11-10

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?

CodePudding user response:

Can be done in several lines.

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