From 45f395ca6f1ef4a44c3b9fa277de1205fcdb48fa Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Wed, 25 Aug 2021 16:12:29 +0100 Subject: [PATCH 1/2] Add docs for munit module --- build.sbt | 5 +++- docs/src/main/mdoc/modules.md | 28 +++++++++++++++++++ docs/src/main/mdoc/overview.md | 7 +++++ docs/src/main/scala/fs2/kafka/docs/Main.scala | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 37a86b406..2670485da 100644 --- a/build.sbt +++ b/build.sbt @@ -95,7 +95,7 @@ lazy val docs = project mdocSettings, buildInfoSettings ) - .dependsOn(core, vulcan) + .dependsOn(core, vulcan, `vulcan-testkit-munit`) .enablePlugins(BuildInfoPlugin, DocusaurusPlugin, MdocPlugin, ScalaUnidocPlugin) lazy val dependencySettings = Seq( @@ -182,6 +182,9 @@ lazy val buildInfoSettings = Seq( BuildInfoKey.map(vulcan / crossScalaVersions) { case (k, v) => "vulcan" ++ k.capitalize -> v }, + BuildInfoKey.map(`vulcan-testkit-munit` / moduleName) { + case (k, v) => "vulcanTeskkitMunit" ++ k.capitalize -> v + }, LocalRootProject / organization, core / crossScalaVersions, BuildInfoKey("fs2Version" -> fs2Version), diff --git a/docs/src/main/mdoc/modules.md b/docs/src/main/mdoc/modules.md index 857f1701e..9c7a6931f 100644 --- a/docs/src/main/mdoc/modules.md +++ b/docs/src/main/mdoc/modules.md @@ -130,3 +130,31 @@ avroSettingsSharedClient.map { avroSettings => (consumerSettings, producerSettings) } ``` + +## Vulcan testkit munit + +The `@VULCAN_TESTKIT_MUNIT_MODULE_NAME@` module provides an [munit](https://scalameta.org/munit/) fixture for testing vulcan +codecs against a [schema registry](https://docs.confluent.io/platform/current/schema-registry/index.html) + +A usage example: + +```scala mdoc:reset +import fs2.kafka.vulcan.SchemaRegistryClientSettings +import org.apache.avro.SchemaCompatibility.SchemaCompatibilityType +import fs2.kafka.vulcan.testkit.SchemaSuite +import vulcan.Codec + +class MySpec extends SchemaSuite { + val checker = compatibilityChecker(SchemaRegistryClientSettings("https://some-schema-registry:1234")) + + override def munitFixtures = List(checker) + + test("my codec is compatible") { + val myCodec: Codec[String] = ??? + + val compatibility = checker().checkReaderCompatibility(myCodec, "my-schema-subject").unsafeRunSync() + + assertEquals(compatibility.getType(), SchemaCompatibilityType.COMPATIBLE, compatibility.getResult().getIncompatibilities()) + } +} +``` \ No newline at end of file diff --git a/docs/src/main/mdoc/overview.md b/docs/src/main/mdoc/overview.md index 3e45ff623..fae4e4333 100644 --- a/docs/src/main/mdoc/overview.md +++ b/docs/src/main/mdoc/overview.md @@ -33,6 +33,13 @@ resolvers += "confluent" at "https://packages.confluent.io/maven/" libraryDependencies += "@ORGANIZATION@" %% "@VULCAN_MODULE_NAME@" % "@LATEST_VERSION@" ``` +In order to test vulcan codecs against a [schema registry](https://docs.confluent.io/platform/current/schema-registry/index.html) using +[munit](https://scalameta.org/munit/), add the following line to your `build.sbt` file. + +```scala +libraryDependencies += "@ORGANIZATION@" %% "@VULCAN_TESTKIT_MUNIT_MODULE_NAME@" % "@LATEST_VERSION@" +``` + ### Signatures Stable release artifacts are signed with the [`E97C 64AB 4987 7F74`](https://keys.openpgp.org/search?q=D9A5006CBC771CEAEB0CA118E97C64AB49877F74) key. diff --git a/docs/src/main/scala/fs2/kafka/docs/Main.scala b/docs/src/main/scala/fs2/kafka/docs/Main.scala index 1c8537b73..42c6ad034 100644 --- a/docs/src/main/scala/fs2/kafka/docs/Main.scala +++ b/docs/src/main/scala/fs2/kafka/docs/Main.scala @@ -37,6 +37,7 @@ object Main { "CORE_CROSS_SCALA_VERSIONS" -> minorVersionsString(coreCrossScalaVersions), "VULCAN_MODULE_NAME" -> vulcanModuleName, "VULCAN_CROSS_SCALA_VERSIONS" -> minorVersionsString(vulcanCrossScalaVersions), + "VULCAN_TESTKIT_MUNIT_MODULE_NAME" -> vulcanTeskkitMunitModuleName, "LATEST_VERSION" -> latestVersion, "LATEST_SNAPSHOT_VERSION" -> latestSnapshotVersion, "LATEST_MAJOR_VERSION" -> majorVersion(latestVersion), From c4a47dd3e1ebb7a623659f63f1c12e0ef1fc1b67 Mon Sep 17 00:00:00 2001 From: Keir Lawson Date: Wed, 25 Aug 2021 16:47:30 +0100 Subject: [PATCH 2/2] Correct var name --- build.sbt | 2 +- docs/src/main/scala/fs2/kafka/docs/Main.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 2670485da..d70e891f4 100644 --- a/build.sbt +++ b/build.sbt @@ -183,7 +183,7 @@ lazy val buildInfoSettings = Seq( case (k, v) => "vulcan" ++ k.capitalize -> v }, BuildInfoKey.map(`vulcan-testkit-munit` / moduleName) { - case (k, v) => "vulcanTeskkitMunit" ++ k.capitalize -> v + case (k, v) => "vulcanTestkitMunit" ++ k.capitalize -> v }, LocalRootProject / organization, core / crossScalaVersions, diff --git a/docs/src/main/scala/fs2/kafka/docs/Main.scala b/docs/src/main/scala/fs2/kafka/docs/Main.scala index 42c6ad034..b3a66e5a5 100644 --- a/docs/src/main/scala/fs2/kafka/docs/Main.scala +++ b/docs/src/main/scala/fs2/kafka/docs/Main.scala @@ -37,7 +37,7 @@ object Main { "CORE_CROSS_SCALA_VERSIONS" -> minorVersionsString(coreCrossScalaVersions), "VULCAN_MODULE_NAME" -> vulcanModuleName, "VULCAN_CROSS_SCALA_VERSIONS" -> minorVersionsString(vulcanCrossScalaVersions), - "VULCAN_TESTKIT_MUNIT_MODULE_NAME" -> vulcanTeskkitMunitModuleName, + "VULCAN_TESTKIT_MUNIT_MODULE_NAME" -> vulcanTestkitMunitModuleName, "LATEST_VERSION" -> latestVersion, "LATEST_SNAPSHOT_VERSION" -> latestSnapshotVersion, "LATEST_MAJOR_VERSION" -> majorVersion(latestVersion),