Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lforite/659f4f73f348df18bea62cd2019cb7af to your computer and use it in GitHub Desktop.
Save lforite/659f4f73f348df18bea62cd2019cb7af to your computer and use it in GitHub Desktop.
Scala web series Pt. 1 testing our custom predicates
"HasProject" should {
"return true for any user who has this project" in {
forAll("projectId", "allProjects") { (projectId: UUID, allProjects: Set[UUID]) =>
val projects = (allProjects + projectId).toSeq
HasProject(projectId).evaluate(
Token(..., projectIds = projectIds)
) mustBe true
}
}
"return false for any user who has not access to this project" in {
forAll("projectId", "allProjects") { (projectId: UUID, allProjects: Set[UUID]) =>
val projectIds = (allProjects - projectId).toSeq
HasProject(projectId).evaluate(
Token(..., projectIds = projectIds)
) mustBe false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment