8000 Implement MockRandom#nextUUID by adamgfraser · Pull Request #6100 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Implement MockRandom#nextUUID #6100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2021
Merged

Implement MockRandom#nextUUID #6100

merged 1 commit into from
Nov 26, 2021

Conversation

adamgfraser
Copy link
Contributor

No description provided.

@stevebakh
Copy link

Thanks for introducing this change @adamgfraser. For the record, it appears nextuuid has also been missed out of TestRandom too, i.e. there's no way to feed the buffer with a set of UUID's to use in tests.

For context, I was attempting to write a test that verifies my code uses ZIO random to generate a UUID and invoke another service with that value. I'm using the test generators to generate a random UUID each time the test is executed. This is then used in the test as part of a mock expectation to verify that the code being tested uses ZIO Random to generate a UUID and pass it to the mocked injected service. e.g. tell MockRandom to return the generated value when calling nextUUID, and then check that this same value is passed along.

For now, I've created my own Mock Random (essentially a copy pasta of the file in your commit) until this is backported into ZIO.

@adamgfraser
Copy link
Contributor Author

@stevebakh It already exists and will be available in the next release.

def feedUUIDs(UUIDs: UUID*): URIO[TestRandom, Unit] =

@jdegoes jdegoes merged commit 6b42b5e into zio:master Nov 26, 2021
@adamgfraser adamgfraser deleted the mockrandom branch December 22, 2021 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0