Temporal mock expectation with map object


I’ve made some unit tests for my application with temporal. Here is the issue:

  1. I’ve made expect construction for mock, containing map object inside:
env.OnActivity(activities.GetRefs, mock.Anything, activities.MyParams{}}).Return(activities.RefsResult{
        MyMap: map[string]string{"1": "one",  "2": "two"},
    }, nil)
  1. Sometimes expectations are failed (unit test hence) since maps are not equal inside expect method, even though, logically, they are equal.

So the question is how can I achieve maps equality check inside temporal mock?

@maxim Hello!

May I ask you for help in this topic?
I would greatly appreciate any assistance or advice. Thank you in advance for your time.

Temporal internally relies on the Go mock package. OnActivity corresponds to Mock.On function.

The problem is not temporal-specific so you can check its documentation and samples.

1 Like