From 27c37b47cc201bf429c3ed2edc6aa478d09967bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Fri, 5 Jun 2026 15:58:37 +0200 Subject: [PATCH] test(server): add tests for non-sense behavior --- .../mavenbinding/MavenMetadataBuildingTest.kt | 67 +++++++++++++++++-- 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt index db0a8cdb2..9d098ca8e 100644 --- a/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt +++ b/maven-binding-builder/src/test/kotlin/io/github/typesafegithub/workflows/mavenbinding/MavenMetadataBuildingTest.kt @@ -8,8 +8,11 @@ import io.github.typesafegithub.workflows.actionbindinggenerator.domain.Signific import io.github.typesafegithub.workflows.actionbindinggenerator.domain.SignificantVersion.FULL import io.github.typesafegithub.workflows.shared.internal.model.Version import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder import io.kotest.matchers.nulls.shouldBeNull +import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.matchers.shouldBe +import io.kotest.matchers.shouldNotBe import io.micrometer.core.instrument.MeterRegistry import java.time.ZonedDateTime @@ -47,10 +50,14 @@ class MavenMetadataBuildingTest : ).right() } + var prefetchedCoords: Collection? = null val xml = bindingsServerRequest.buildMavenMetadataFile( githubAuthToken = "SOME_TOKEN", fetchAvailableVersions = fetchAvailableVersions, + prefetchBindingArtifacts = { + prefetchedCoords = it + }, ) xml shouldBe @@ -70,6 +77,19 @@ class MavenMetadataBuildingTest : """.trimIndent() + + prefetchedCoords shouldNotBe null + prefetchedCoords shouldContainExactlyInAnyOrder + listOf( + bindingsServerRequest.actionCoords.copy( + version = "v1", + versionForTypings = "irrelevant", + ), + bindingsServerRequest.actionCoords.copy( + version = "v2", + versionForTypings = "irrelevant", + ), + ) } test("no major versions") { @@ -89,13 +109,21 @@ class MavenMetadataBuildingTest : ).right() } + var prefetchedCoords: Collection? = null val xml = bindingsServerRequest.buildMavenMetadataFile( githubAuthToken = "SOME_TOKEN", fetchAvailableVersions = fetchAvailableVersions, + prefetchBindingArtifacts = { + prefetchedCoords = it + }, ) xml.shouldBeNull() + + prefetchedCoords shouldNotBeNull { + size shouldBe 0 + } } test("no versions available") { @@ -109,24 +137,27 @@ class MavenMetadataBuildingTest : emptyList().right() } + var prefetchedCoords: Collection? = null val xml = bindingsServerRequest.buildMavenMetadataFile( githubAuthToken = "SOME_TOKEN", fetchAvailableVersions = fetchAvailableVersions, + prefetchBindingArtifacts = { + prefetchedCoords = it + }, ) xml.shouldBeNull() + + prefetchedCoords shouldNotBeNull { + size shouldBe 0 + } } (SignificantVersion.entries - FULL).forEach { significantVersion -> test("significant version $significantVersion requested") { // Given - val fetchAvailableVersions: suspend ( - String, - String, - String?, - MeterRegistry?, - ) -> Either> = { owner, name, _, _ -> + var availableVersions = listOf( Version( version = "v3-beta", @@ -168,9 +199,17 @@ class MavenMetadataBuildingTest : shaProvider = { "8" }, dateProvider = { ZonedDateTime.parse("2024-03-01T00:00:00Z") }, ), - ).right() + ) + val fetchAvailableVersions: suspend ( + String, + String, + String?, + MeterRegistry?, + ) -> Either> = { owner, name, _, _ -> + availableVersions.right() } + var prefetchedCoords: Collection? = null val xml = bindingsServerRequest .copy( @@ -182,6 +221,9 @@ class MavenMetadataBuildingTest : ).buildMavenMetadataFile( githubAuthToken = "SOME_TOKEN", fetchAvailableVersions = fetchAvailableVersions, + prefetchBindingArtifacts = { + prefetchedCoords = it + }, ) val commitLenient = significantVersion == COMMIT_LENIENT @@ -208,6 +250,17 @@ class MavenMetadataBuildingTest : """.trimIndent() + + prefetchedCoords shouldNotBe null + prefetchedCoords shouldContainExactlyInAnyOrder + availableVersions.map { availableVersion -> + bindingsServerRequest.actionCoords.copy( + version = "$availableVersion", + comment = null, + significantVersion = significantVersion, + versionForTypings = "irrelevant", + ) + } } } })