Skip to content

Commit

Permalink
PLATUI-3061: Use an integration test to compare Github main service f…
Browse files Browse the repository at this point in the history
…iles with local
  • Loading branch information
JoPintoPaul committed May 30, 2024
1 parent 9440c36 commit 1768f80
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ play.http.router = prod.Routes
play.filters.enabled += play.filters.csp.CSPFilter

# Default http client
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientModule"
play.modules.enabled += "uk.gov.hmrc.play.bootstrap.HttpClientV2Module"

# Custom error handler
play.http.errorHandler = "uk.gov.hmrc.accessibilitystatementfrontend.handlers.ErrorHandler"
Expand Down
13 changes: 0 additions & 13 deletions conf/services/example-chgv.yml

This file was deleted.

29 changes: 27 additions & 2 deletions test/it/ServicesISpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ import org.scalatestplus.play.guice.GuiceOneAppPerSuite
import uk.gov.hmrc.accessibilitystatementfrontend.config.{AppConfig, ServicesFinder, SourceConfig}
import uk.gov.hmrc.accessibilitystatementfrontend.models._
import uk.gov.hmrc.accessibilitystatementfrontend.parsers.AccessibilityStatementParser
import org.scalatest.AppendedClues.convertToClueful
import play.api.libs.json.JsValue
import play.api.test.WsTestClient
import uk.gov.hmrc.http.HeaderCarrier
import uk.gov.hmrc.http.client.HttpClientV2

import java.io.File
import java.net.URLDecoder
import java.net.{URL, URLDecoder}
import scala.concurrent.Await
import scala.concurrent.duration._
import java.util.concurrent.TimeUnit.SECONDS
import scala.util.Try

class ServicesISpec extends AnyWordSpec with Matchers with GuiceOneAppPerSuite with TryValues {
class ServicesISpec extends AnyWordSpec with Matchers with GuiceOneAppPerSuite with TryValues with WsTestClient {
private val statementParser = new AccessibilityStatementParser

private val partiallyCompliantWithoutMilestones: Seq[String] =
Expand Down Expand Up @@ -280,5 +288,22 @@ class ServicesISpec extends AnyWordSpec with Matchers with GuiceOneAppPerSuite w
services.contains(serviceName) should be(true)
}
}

"match the files in Github" in {
import scala.concurrent.ExecutionContext.Implicits.global

val client = app.injector.instanceOf[HttpClientV2]
val url: URL = new URL("https://api.github.com/repos/hmrc/accessibility-statement-frontend/contents/conf/services")
val files =
Await.result(client.get(url)(HeaderCarrier()).execute[Seq[JsValue]], Duration(2, SECONDS))

val fileNamesFromGithub = files.map(file =>(file \ "name").as[String])

val maybeDeletedFiles = fileNamesFromGithub.diff(fileNames)
maybeDeletedFiles.isEmpty should be(
true
) withClue (s", The following files from the Github are not found in the services directory: $maybeDeletedFiles")

}
}
}

0 comments on commit 1768f80

Please sign in to comment.