From 1ec73d4b9c190a98dfedf858f6fafb5707bbd7a9 Mon Sep 17 00:00:00 2001 From: Roberto Tyley Date: Wed, 29 Jun 2022 17:28:59 +0100 Subject: [PATCH] Add test to spot FAPI/CAPI incompatability We're adding a test that will break at build time rather than runtime if our versions of the FAPI & CAPI clients are incompatible. See also: * https://github.com/guardian/frontend/pull/25139#issuecomment-1163407402 * https://github.com/guardian/ophan/pull/4719/files#diff-ee7f97c92065084bba37d70d043ad0daa0d7745f235d0ad3206b59f073829529 --- .../test/frontpress/FaciaClientTest.scala | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 facia-press/test/frontpress/FaciaClientTest.scala diff --git a/facia-press/test/frontpress/FaciaClientTest.scala b/facia-press/test/frontpress/FaciaClientTest.scala new file mode 100644 index 000000000000..8edeff2c7518 --- /dev/null +++ b/facia-press/test/frontpress/FaciaClientTest.scala @@ -0,0 +1,35 @@ +package frontpress + +import com.gu.contentapi.client.model.SearchQuery +import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures} +import org.scalatest.{BeforeAndAfterAll, EitherValues} +import org.scalatest.flatspec._ +import org.scalatest.matchers.should.Matchers +import test.{SingleServerSuite, WithMaterializer, WithTestContentApiClient, WithTestWsClient} + +class FaciaClientTest extends AnyFlatSpec with Matchers + with ScalaFutures + with IntegrationPatience + with SingleServerSuite + with BeforeAndAfterAll + with WithMaterializer + with WithTestWsClient + with WithTestContentApiClient + with EitherValues { + + "FAPI Client" should "perform a CAPI-client request without a runtime error like java.lang.NoSuchMethodError" in { + // See https://github.com/guardian/frontend/pull/25139#issuecomment-1163407402 + // The FAPI client uses the Content API client. If this test fails with a java.lang.NoSuchMethodError, the + // versions of FAPI client and CAPI client we are using are incompatible - the FAPI client will have been + // compiled against a different version of the CAPI client. + + whenReady(com.gu.facia.api.contentapi.ContentApi.getHydrateResponse(testContentApiClient.thriftClient, Seq( + SearchQuery().tag("profile/roberto-tyley"), + SearchQuery().tag("stage/comedy") + )).asFuture) { responses => + val boo: Int = responses.value.size + boo shouldBe(2) + } + } + +}