Skip to content

Commit

Permalink
Make mill-plugin-itest work
Browse files Browse the repository at this point in the history
  • Loading branch information
sake92 committed Aug 16, 2024
1 parent a20b4af commit 4228eab
Show file tree
Hide file tree
Showing 5 changed files with 48,657 additions and 9 deletions.
20 changes: 11 additions & 9 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object squery extends CommonScalaModule with CiReleaseModule {
object generator extends ScalaModule with CiReleaseModule {
def artifactName = "squery-generator"

override def scalaVersion = scala213
def scalaVersion = scala213

def pomSettings = PomSettings(
organization = "ba.sake",
Expand Down Expand Up @@ -85,12 +85,12 @@ object `mill-plugin` extends ScalaModule with CiReleaseModule with ScalafmtModul
def millBinaryVersion(millVersion: String) =
scalaNativeBinaryVersion(millVersion)

override def scalaVersion = scala213
def scalaVersion = scala213

override def artifactName =
def artifactName =
s"mill-squery-generator_mill${millBinaryVersion(millVersion)}"

override def pomSettings = PomSettings(
def pomSettings = PomSettings(
description = "Mill plugin for generating squery source code",
organization = "ba.sake",
url = "https://github.com/sake92/squery",
Expand All @@ -99,7 +99,7 @@ object `mill-plugin` extends ScalaModule with CiReleaseModule with ScalafmtModul
developers = Seq(Developer("sake92", "Sakib Hadziavdic", "https://github.com/sake92"))
)

override def compileIvyDeps = super.compileIvyDeps() ++ Agg(
def compileIvyDeps = super.compileIvyDeps() ++ Agg(
ivy"com.lihaoyi::mill-scalalib:${millVersion}"
)

Expand All @@ -113,19 +113,21 @@ object `mill-plugin` extends ScalaModule with CiReleaseModule with ScalafmtModul
ivy"com.oracle.database.jdbc:ojdbc8:23.3.0.23.09"
)

override def scalacOptions = Seq("-Ywarn-unused", "-deprecation")
def scalacOptions = Seq("-Ywarn-unused", "-deprecation")

}

object `mill-plugin-itest` extends MillIntegrationTestModule {

override def millTestVersion = millVersion
def millTestVersion = millVersion

def pluginsUnderTest = Seq(`mill-plugin`)

override def pluginsUnderTest = Seq(`mill-plugin`)
def temporaryIvyModules = Seq(squery)

def testBase = millSourcePath / "src"

override def testInvocations: T[Seq[(PathRef, Seq[TestInvocation.Targets])]] =
def testInvocations: T[Seq[(PathRef, Seq[TestInvocation.Targets])]] =
T {
Seq(
PathRef(testBase / "h2") -> Seq(
Expand Down
52 changes: 52 additions & 0 deletions mill-plugin-itest/src/h2/build.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import $ivy.`org.scalameta::munit:0.7.29`
import $ivy.`com.lihaoyi::mill-contrib-flyway:`
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $file.plugins

import mill._, scalalib._
import de.tobiasroeser.mill.vcs.version.VcsVersion
import contrib.flyway.FlywayModule
import munit.Assertions._
import ba.sake.squery.generator.mill._

// https://github.com/maxandersen/sakila-h2
object root extends ScalaModule with SqueryGeneratorModule with FlywayModule {
def scalaVersion = "3.4.2"

def ivyDeps = Agg(
ivy"com.zaxxer:HikariCP:4.0.3",
ivy"com.h2database:h2:2.3.232",
ivy"ba.sake::squery:0.3.0-8-a20b4a-DIRTY8921b651-SNAPSHOT"
)

def flywayDriverDeps = Agg(ivy"com.h2database:h2:2.3.232")
def flywayUrl = "jdbc:h2:./h2_pagila"

def squeryJdbcUrl = "jdbc:h2:./h2_pagila"
def squeryUsername = ""
def squeryPassword = ""
def squerySchemas = Seq("PUBLIC" -> "public")

object test extends ScalaTests with TestModule.Munit {
def ivyDeps = Agg(
ivy"org.scalameta::munit:0.7.29"
)
}
}

def verify(): Command[Unit] = T.command {
root.flywayMigrate()()

root.squeryGenerate()()

val generatedModels = os.walk(root.squeryTargetDir() / "public" / "models").filter(os.isFile)
assertEquals(generatedModels.size, 17) // 16 + flyway table..
assert(generatedModels.map(_.last).contains("ActorRow.scala"), "ActorRow was not generated")

val generatedDaos = os.walk(root.squeryTargetDir() / "public" / "daos").filter(os.isFile)
assertEquals(generatedDaos.size, 17)
assert(generatedDaos.map(_.last).contains("ActorCrudDao.scala"), "ActorCrudDao was not generated")

root.test.test()()
()
}
Loading

0 comments on commit 4228eab

Please sign in to comment.