question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mocks only work for single fiber programs

See original GitHub issue

Observed:

  • 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 (using foreachParN) 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
erikvanoostencommented, Jan 11, 2021

That is very good news! Let’s close this issue then.

0reactions
senia-psmcommented, Jan 11, 2021

@erikvanoosten it seems like version 1.0.3+118-51b5bbe0-SNAPSHOT is too old. I published zio locally (with sbt +publishLocal) and tested your code with local version - both tests are green.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found