How to match private struct types using Ginkgo and Gomega?

682 Views Asked by At

Assume that I have a function called GetQueue with GoLang and depends on the configuration, it would return different types of queue implementations.

func GetQueue(config string) *service.Queue {
switch(config):
case "A":
  return &QueueA.NewQueue{...}
case "B":
  return &QueueB.NewQueue{...}
...
}

The service.Queue is an interface. And both QueueA and QueueB are implementations for this interface. The QueueA.go looks like:

type service struct {
...
}

function NewService() *service.Queue {
  return &service{}
}

I'd like to write a unit test for the GetQueue function (which is defined outside of the service package) and I would like to verify the returned types are as expected. However, both QueueA.sevice and QueueB.service are private structs. So how can I verify the returned types are the expected ones?

0

There are 0 best solutions below