Mocks only work for single fiber programs
See original GitHub issueObserved:
- When a fiber uses a mock defined in another fiber, while there is a missing expectations, the test hangs and no error message is printed.
- When several fibers are using a mock (e.g. using
foreachPar
) with multiple expectations (combined with&&
because order can not be guaranteed from multiple fibers), the test never passes. Reducing parallelism to 1 (usingforeachParN
) the test does pass.
Expected:
- Which fiber using the mock does not matter. Missing expectation should always be visible.
- Expectations combined with
&&
should be usable even when called from multiple fibers concurrently.
Is this a known limitation? Are there plans to solve this?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:13 (12 by maintainers)
Top Results From Across the Web
Unit Testing Your Go Webserver Using Mocks - Level Up Coding
This article should show you how to use mocks in your Go tests ... In this example, I am using Go Fiber as...
Read more >unit testing - How much mocking is "just right?"
Personally, I just call all test objects "mocks" because distinguishing between the variety of them isn't often useful.
Read more >Golang “Mocking” a Function for Unit Testing | by Aditya Rama
Inside the mockFunc, we will mock both functions (GetPersonByID and GetPersonAddrByUserID) to just return a constant value depends on our ...
Read more >jest.mock() only works within jestSetup.js - Stack Overflow
I have jest mocks (mocked functions, modules and components) in my jestSetup.js file (pointed to from package.json ), and I also have mocks...
Read more >Improving Your Go Tests and Mocks With Testify
Now, if you are using Go Modules then this will just be a case of calling ... try and modify this basic approach...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That is very good news! Let’s close this issue then.
@erikvanoosten it seems like version
1.0.3+118-51b5bbe0-SNAPSHOT
is too old. I publishedzio
locally (withsbt +publishLocal
) and tested your code with local version - both tests are green.