Skip to content

mock - get call count/list in thread safe way #964

@nbaztec

Description

@nbaztec

What
Currently retrieving the calls via mock.Calls results in a data race condition when the test is using multiple go routines.

Expected
A thread-safe way to obtain the call count/list.

Use Case
A poller object uses a mocked client that is called in an infinite polling loop until a private flag is set on the poller object to exit it. Testing that upon setting the private flag, the infinite loop is no longer invoking the mocked client's method.
This would be trivial to do if we'd have access to the call-count after the flag is set, and if the call count stays the same after 1 second.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions