Created
March 26, 2022 17:31
-
-
Save supermanue/805e3c0211ed51dc532a2c0e102014e9 to your computer and use it in GitHub Desktop.
type generators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait DomainFixtures { | |
def positiveIntGen: Gen[Random, Int] = anyInt.map(num => math.abs(num) + 1) | |
def nonemptyStringGen: Gen[Random with Sized, String] = (anyASCIIString <*> anyChar).map(elems => elems._1 + elems._2) | |
def userGen: Gen[Random with Sized, User] = | |
(positiveIntGen <*> nonemptyStringGen).map(elems => | |
User.build(elems._1, elems._2).getOrElse(throw new Exception("Exception in test building customer")) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment