From 5483e023a2934d50f4e92d8268616779f76bf3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Richez?= Date: Thu, 5 Oct 2023 11:01:21 +0200 Subject: [PATCH] add smoke test and remove play json from the dependencies (#74) * remove play json from the dependencies It should not be necessary since it's pulled by the play framework * Add a smoke test for the application * add smoke test in scalatest instead of bash script --- .github/workflows/scala.yml | 2 ++ build.sbt | 1 - test/integration/SmokeTest.scala | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/integration/SmokeTest.scala diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index e3e9b28..477fcce 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -19,4 +19,6 @@ jobs: java-version: '11' distribution: 'adopt' - name: Run tests + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: sbt test diff --git a/build.sbt b/build.sbt index 3d24001..c1c2894 100644 --- a/build.sbt +++ b/build.sbt @@ -12,7 +12,6 @@ libraryDependencies ++= Seq( "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test, "org.asciidoctor" % "asciidoctorj" % "2.5.10", "com.47deg" %% "github4s" % "0.21.0", - "com.typesafe.play" %% "play-json" % "2.10.1", ) Global / onChangedBuildSource := ReloadOnSourceChanges diff --git a/test/integration/SmokeTest.scala b/test/integration/SmokeTest.scala new file mode 100644 index 0000000..5612319 --- /dev/null +++ b/test/integration/SmokeTest.scala @@ -0,0 +1,28 @@ + +import org.scalatestplus.play.PlaySpec +import org.scalatestplus.play.guice.GuiceOneServerPerSuite +import play.api.libs.ws.WSClient +import org.scalatest._ +import org.scalatestplus.play._ + +import play.api.test._ +import play.api.test.Helpers.{GET => GET_REQUEST, _} +import play.api.Application +import play.api.inject.guice.GuiceApplicationBuilder + +class SmokeTest extends PlaySpec with GuiceOneServerPerSuite { + + override def fakeApplication(): Application = { + GuiceApplicationBuilder() + .configure( + "accessToken" -> sys.env.get("GITHUB_TOKEN").getOrElse("dummy") + ) + .build() + } + + "should return some page" in { + val wsClient = app.injector.instanceOf[WSClient] + val response = await(wsClient.url(s"http://localhost:$port/").withVirtualHost("blog.lunatech.com").get()) + response.status mustBe OK + } +}