Skip to content

Commit 53d6a96

Browse files
krzema12Vampire
andauthored
test: add tests reproducing no typings for non-major version for subactions (#2256)
Part of #2253. A follow-up to the previous change where we didn't take into account subactions. --------- Co-authored-by: Björn Kautler <Bjoern@Kautler.net>
1 parent 5e79f27 commit 53d6a96

1 file changed

Lines changed: 88 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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,94 @@ class TypesProvidingTest :
752752
)
753753
}
754754

755+
test("only stored in typing catalog for older version of subaction using non-major version") {
756+
// Given
757+
val mockClient =
758+
HttpClient(
759+
MockEngine { request ->
760+
if (request.url.toString() ==
761+
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
762+
"main/typings/some-owner/some-name/metadata.yml"
763+
) {
764+
respond(metadata)
765+
} else if (request.url.toString() ==
766+
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
767+
"main/typings/some-owner/some-name/v4/some-sub/action-types.yml"
768+
) {
769+
respond(storedInTypingCatalogForOlderVersion)
770+
} else {
771+
respond("Not found", status = HttpStatusCode.NotFound)
772+
}
773+
},
774+
)
775+
val actionCoord = ActionCoords("some-owner", "some-name", "v6.1.2", FULL, path = "some-sub")
776+
777+
// When
778+
val types =
779+
actionCoord.provideTypes(
780+
metadataRevision = CommitHash("some-hash"),
781+
httpClient = mockClient,
782+
)
783+
784+
// Then
785+
types shouldBe
786+
// This assertion shows an undesired behavior - a result of a regression.
787+
// TODO: fix it in scope of https://github.com/typesafegithub/github-workflows-kt/issues/2253
788+
ActionTypings(
789+
inputTypings = emptyMap(),
790+
source = null,
791+
fromFallbackVersion = false,
792+
)
793+
}
794+
795+
test("only stored in typing catalog for older version of subaction using commit pinning") {
796+
// Given
797+
val mockClient =
798+
HttpClient(
799+
MockEngine { request ->
800+
if (request.url.toString() ==
801+
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
802+
"main/typings/some-owner/some-name/metadata.yml"
803+
) {
804+
respond(metadata)
805+
} else if (request.url.toString() ==
806+
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
807+
"main/typings/some-owner/some-name/v4/some-sub/action-types.yml"
808+
) {
809+
respond(storedInTypingCatalogForOlderVersion)
810+
} else {
811+
respond("Not found", status = HttpStatusCode.NotFound)
812+
}
813+
},
814+
)
815+
val actionCoord =
816+
ActionCoords(
817+
"some-owner",
818+
"some-name",
819+
"some-hash",
820+
FULL,
821+
versionForTypings = "v6.1.2",
822+
path = "some-sub",
823+
)
824+
825+
// When
826+
val types =
827+
actionCoord.provideTypes(
828+
metadataRevision = CommitHash("some-hash"),
829+
httpClient = mockClient,
830+
)
831+
832+
// Then
833+
types shouldBe
834+
// This assertion shows an undesired behavior - a result of a regression.
835+
// TODO: fix it in scope of https://github.com/typesafegithub/github-workflows-kt/issues/2253
836+
ActionTypings(
837+
inputTypings = emptyMap(),
838+
source = null,
839+
fromFallbackVersion = false,
840+
)
841+
}
842+
755843
test("metadata available but no version available") {
756844
// Given
757845
val mockClient =

0 commit comments

Comments
 (0)