Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

Commit

Permalink
#7, test: Add scripted tests to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
slavaschmidt committed Feb 9, 2016
1 parent 94f4dc4 commit 89e0130
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 36 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: scala

scala:
- 2.10.5
- 2.11.7

branches:
only:
Expand All @@ -20,4 +21,11 @@ before_install:
- pip install --user codecov

after_success:
- codecov
- codecov

script:
- sbt compile test:compile test
- sbt +publishLocal scripted

# Trick to avoid unnecessary cache updates
- find $HOME/.sbt -name "*.lock" | xargs rm
11 changes: 7 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ lazy val plugin = (project in file("plugin"))
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "de.zalando",

scriptedLaunchOpts := { scriptedLaunchOpts.value ++
Seq("-Dproject.version=" + version.value)
scriptedLaunchOpts := {
scriptedLaunchOpts.value ++
Seq(
"-Dproject.version=" + version.value,
"-Dscala.version=" + scalaVersion.value
)
},
scriptedDependencies := {
// Ensure everything is published before scripted runs
val a = (publishLocal in api).value
val b = (publishLocal in compiler).value
val c = publishLocal.value
Expand All @@ -87,7 +90,7 @@ lazy val root = (project in file("."))

def common: Seq[Setting[_]] = bintrayPublishSettings ++ Seq(
organization := "de.zalando",
version := "0.1.4",
version := "0.1.6",
fork in ( Test, run ) := true,
autoScalaLibrary := true,
resolvers ++= Seq(
Expand Down
13 changes: 7 additions & 6 deletions plugin/src/sbt-test/swagger/compile/build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
lazy val root = (project in file("."))
.enablePlugins(PlayScala, PlaySwagger)
lazy val root = (project in file(".")).enablePlugins(PlayScala, PlaySwagger)

scalaVersion := "2.11.7"
scalaVersion := sys.props.get("scala.version").getOrElse("2.11.7")

crossPaths := false

routesGenerator := InjectedRoutesGenerator

libraryDependencies ++= Seq(
specs2,
"org.scalacheck" %% "scalacheck" % "1.12.4",
"org.specs2" %% "specs2-scalacheck" % "3.6"
specs2 % "test",
"org.scalacheck" %% "scalacheck" % "1.12.4" % "test",
"org.specs2" %% "specs2-scalacheck" % "3.6" % "test"
)
51 changes: 26 additions & 25 deletions plugin/src/sbt-test/swagger/compile/test
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
# Project is clean, nothing is here

- $ exists app/controllers/echo.api.yaml.scala
- $ exists target/scala-2.11/routes/main/controllers_base/echo.api.yaml.scala
- $ exists target/scala-2.11/routes/main/model/echo.api.yaml.scala
- $ exists target/scala-2.11/routes/main/validators/echo.api.yaml.scala
- $ exists target/scala-2.11/routes/test/tests/echo.api.yaml.scala
- $ exists target/scala-2.11/routes/test/generators/echo.api.yaml.scala
$ absent app/controllers/echo.api.yaml.scala
$ absent target/routes/main/controllers_base/echo.api.yaml.scala
$ absent target/routes/main/model/echo.api.yaml.scala
$ absent target/routes/main/validators/echo.api.yaml.scala
$ absent target/routes/test/tests/echo.api.yaml.scala
$ absent target/routes/test/generators/echo.api.yaml.scala

# Fails while compiled for the first time because of missing controllers
> clean
-> compile

- $ exists app/controllers/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/controllers_base/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/model/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/validators/echo.api.yaml.scala
$ absent app/controllers/echo.api.yaml.scala
$ exists target/routes/main/controllers_base/echo.api.yaml.scala
$ exists target/routes/main/model/echo.api.yaml.scala
$ exists target/routes/main/validators/echo.api.yaml.scala

# The controller generation must be triggered explicitly
> swaggerCompileControllers

# only single controller was generated

$ exists app/controllers/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/controllers_base/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/model/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/validators/echo.api.yaml.scala
- $ exists target/scala-2.11/routes/test/tests/echo.api.yaml.scala
- $ exists target/scala-2.11/routes/test/generators/echo.api.yaml.scala
$ exists target/routes/main/controllers_base/echo.api.yaml.scala
$ exists target/routes/main/model/echo.api.yaml.scala
$ exists target/routes/main/validators/echo.api.yaml.scala
$ absent target/routes/test/tests/echo.api.yaml.scala
$ absent target/routes/test/generators/echo.api.yaml.scala

# Successfully compiles after controllers have being generated
> clean
Expand All @@ -34,22 +35,22 @@ $ exists target/scala-2.11/routes/main/validators/echo.api.yaml.scala

# no test data exists yet
$ exists app/controllers/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/model/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/validators/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/controllers_base/echo.api.yaml.scala
- $ exists target/scala-2.11/routes/test/tests/echo.api.yaml.scala
- $ exists target/scala-2.11/routes/test/generators/echo.api.yaml.scala
$ exists target/routes/main/model/echo.api.yaml.scala
$ exists target/routes/main/validators/echo.api.yaml.scala
$ exists target/routes/main/controllers_base/echo.api.yaml.scala
$ absent target/routes/test/tests/echo.api.yaml.scala
$ absent target/routes/test/generators/echo.api.yaml.scala

# Tests should fail with 404 because there is no mapping in routes file
-> test

# now everything must be present
$ exists target/scala-2.11/routes/test/tests/echo.api.yaml.scala
$ exists target/scala-2.11/routes/test/generators/echo.api.yaml.scala
$ exists target/routes/test/tests/echo.api.yaml.scala
$ exists target/routes/test/generators/echo.api.yaml.scala
$ exists app/controllers/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/controllers_base/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/model/echo.api.yaml.scala
$ exists target/scala-2.11/routes/main/validators/echo.api.yaml.scala
$ exists target/routes/main/controllers_base/echo.api.yaml.scala
$ exists target/routes/main/model/echo.api.yaml.scala
$ exists target/routes/main/validators/echo.api.yaml.scala

# we don't check what is created by the play's routes compiler because its outside of our control

0 comments on commit 89e0130

Please sign in to comment.