Skip to content

Commit 5e79f27

Browse files
krzema12Vampire
andauthored
test: add reproducers for no typings for non-major version (#2254)
Part of #2253. The goal is to show the currrent behavior before it's fixed. Co-authored-by: Björn Kautler <Bjoern@Kautler.net>
1 parent e69d5ba commit 5e79f27

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

  • action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,86 @@ class TypesProvidingTest :
596596
)
597597
}
598598

599+
test("only stored in typing catalog for older version using non-major version") {
600+
// Given
601+
val mockClient =
602+
HttpClient(
603+
MockEngine { request ->
604+
if (request.url.toString() ==
605+
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
606+
"main/typings/some-owner/some-name/metadata.yml"
607+
) {
608+
respond(metadata)
609+
} else if (request.url.toString() ==
610+
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
611+
"main/typings/some-owner/some-name/v4/action-types.yml"
612+
) {
613+
respond(storedInTypingCatalogForOlderVersion)
614+
} else {
615+
respond("Not found", status = HttpStatusCode.NotFound)
616+
}
617+
},
618+
)
619+
val actionCoord = ActionCoords("Some-owner", "Some-name", "v6.1.2")
620+
621+
// When
622+
val types =
623+
actionCoord.provideTypes(
624+
metadataRevision = CommitHash("some-hash"),
625+
httpClient = mockClient,
626+
)
627+
628+
// Then
629+
types shouldBe
630+
// This assertion shows an undesired behavior - a result of a regression.
631+
// TODO: fix it in scope of https://github.com/typesafegithub/github-workflows-kt/issues/2253
632+
ActionTypings(
633+
inputTypings = emptyMap(),
634+
source = null,
635+
fromFallbackVersion = false,
636+
)
637+
}
638+
639+
test("only stored in typing catalog for older version using commit pinning") {
640+
// Given
641+
val mockClient =
642+
HttpClient(
643+
MockEngine { request ->
644+
if (request.url.toString() ==
645+
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
646+
"main/typings/some-owner/some-name/metadata.yml"
647+
) {
648+
respond(metadata)
649+
} else if (request.url.toString() ==
650+
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
651+
"main/typings/some-owner/some-name/v4/action-types.yml"
652+
) {
653+
respond(storedInTypingCatalogForOlderVersion)
654+
} else {
655+
respond("Not found", status = HttpStatusCode.NotFound)
656+
}
657+
},
658+
)
659+
val actionCoord = ActionCoords("Some-owner", "Some-name", "some-hash", versionForTypings = "v6.1.2")
660+
661+
// When
662+
val types =
663+
actionCoord.provideTypes(
664+
metadataRevision = CommitHash("some-hash"),
665+
httpClient = mockClient,
666+
)
667+
668+
// Then
669+
types shouldBe
670+
// This assertion shows an undesired behavior - a result of a regression.
671+
// TODO: fix it in scope of https://github.com/typesafegithub/github-workflows-kt/issues/2253
672+
ActionTypings(
673+
inputTypings = emptyMap(),
674+
source = null,
675+
fromFallbackVersion = false,
676+
)
677+
}
678+
599679
test("only stored in typing catalog for older version, under lowercase name and owner") {
600680
// Given
601681
val mockClient =

0 commit comments

Comments
 (0)