agiledragon / gomonkey

gomonkey is a library to make monkey patching in unit tests easy
MIT License
1.92k stars 178 forks source link

Running multiple cases at the same time and reporting errors: panic: double seq is less than call seq #162

Closed kannae97 closed 6 days ago

kannae97 commented 3 months ago

Like this:

image

panic: double seq is less than call seq [recovered] panic: double seq is less than call seq

xhd2015 commented 3 months ago

gomonkey is not concurrent safe, try xgo if you need concurrent safety: https://github.com/xhd2015/xgo

kannae97 commented 3 months ago

gomonkey is not concurrent safe, try xgo if you need concurrent safety: https://github.com/xhd2015/xgo

Thank u, bro.

agiledragon commented 3 weeks ago

@kannae97 This has nothing to do with thread safety. When using sequence patches, ensure the sequence length is at least equal to the number of calls; otherwise, it will panic. Sequence patches emphasize that the return value differs with each call. In this case, the sequence patch length is 1, so using the sequence patch API is meaningless. Using the regular patch API is sufficient since the return value is the same for each call, with no call count limit.