Skip to content

Commit

Permalink
add smoke test and remove play json from the dependencies (#74)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
AurelienRichez authored and pepite committed Sep 2, 2024
1 parent 96b60d8 commit 0b13bb1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ jobs:
java-version: '11'
distribution: 'adopt'
- name: Run tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: sbt test
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 28 additions & 0 deletions test/integration/SmokeTest.scala
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 0b13bb1

Please sign in to comment.