~jan0sch/smederee
Showing details for patch b2466e506a577ea6ae72f053cc674f2fb29e2f80.
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/ssh/DoobieSshAuthenticationRepositoryTest.scala new-smederee/modules/hub/src/test/scala/de/smederee/ssh/DoobieSshAuthenticationRepositoryTest.scala --- old-smederee/modules/hub/src/test/scala/de/smederee/ssh/DoobieSshAuthenticationRepositoryTest.scala 2025-01-10 23:59:07.981155317 +0000 +++ new-smederee/modules/hub/src/test/scala/de/smederee/ssh/DoobieSshAuthenticationRepositoryTest.scala 2025-01-10 23:59:07.981155317 +0000 @@ -9,30 +9,33 @@ import cats.effect.* import cats.syntax.all.* import de.smederee.TestTags.* +import de.smederee.hub.Account import de.smederee.hub.BaseSpec -import de.smederee.hub.Generators.* +import de.smederee.hub.Generators.given import de.smederee.security.* import doobie.* +import org.scalacheck.effect.PropF + final class DoobieSshAuthenticationRepositoryTest extends BaseSpec { + override def scalaCheckTestParameters = super.scalaCheckTestParameters.withMinSuccessfulTests(1) + test("findVcsRepositoryOwner must return the correct owner".tag(NeedsDatabase)) { - genValidAccount.sample match { - case Some(account) => - val dbConfig = configuration.database - val tx = Transactor.fromDriverManager[IO]( - driver = dbConfig.driver, - url = dbConfig.url, - user = dbConfig.user, - password = dbConfig.pass, - logHandler = None - ) - val repo = new DoobieSshAuthenticationRepository[IO](tx) - val test = for { - _ <- createAccount(account, PasswordHash("I am not a password hash!"), None, None) - owner <- repo.findVcsRepositoryOwner(account.name) - } yield owner - test.assertEquals(account.toVcsRepositoryOwner.some) - case _ => fail("Could not generate data samples!") + PropF.forAllF { (account: Account) => + val dbConfig = configuration.database + val tx = Transactor.fromDriverManager[IO]( + driver = dbConfig.driver, + url = dbConfig.url, + user = dbConfig.user, + password = dbConfig.pass, + logHandler = None + ) + val repo = new DoobieSshAuthenticationRepository[IO](tx) + val test = for { + _ <- createAccount(account, PasswordHash("I am not a password hash!"), None, None) + owner <- repo.findVcsRepositoryOwner(account.name) + } yield owner + test.start.flatMap(_.joinWithNever).assertEquals(account.toVcsRepositoryOwner.some) } } }