Skip to content

Instantly share code, notes, and snippets.

@supermanue
Created March 26, 2022 17:31
Show Gist options
  • Save supermanue/805e3c0211ed51dc532a2c0e102014e9 to your computer and use it in GitHub Desktop.
Save supermanue/805e3c0211ed51dc532a2c0e102014e9 to your computer and use it in GitHub Desktop.
type generators
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