Skip to content

Commit d82ade8

Browse files
authored
test(server): add test for requesting non-existent artifact twice (#2182)
Part of #2160, will let us fix the behavior by caching the response of non-existent resource.
1 parent 11c15f4 commit d82ade8

File tree

1 file changed

+32
-0
lines changed
  • jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver

1 file changed

+32
-0
lines changed

jit-binding-server/src/test/kotlin/io/github/typesafegithub/workflows/jitbindingserver/ArtifactRoutesTest.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,38 @@ class ArtifactRoutesTest :
6464
}
6565
}
6666

67+
test("when artifacts is not available, two requests in a row") {
68+
testApplication {
69+
// Given
70+
val mockBuildVersionArtifacts = mockk<(ActionCoords, HttpClient) -> VersionArtifacts?>()
71+
every { mockBuildVersionArtifacts(any(), any()) } returns null
72+
application {
73+
appModule(
74+
buildVersionArtifacts = mockBuildVersionArtifacts,
75+
// Irrelevant for these tests.
76+
buildPackageArtifacts = { _, _, _, _ -> emptyMap() },
77+
getGithubAuthToken = { "" },
78+
)
79+
}
80+
81+
// When
82+
val response = client.get("some-owner/some-action/v4/some-action-v4.pom")
83+
// Then
84+
response.status shouldBe HttpStatusCode.NotFound
85+
86+
// When
87+
val response2 = client.get("some-owner/some-action/v4/some-action-v4.pom")
88+
// Then
89+
response2.status shouldBe HttpStatusCode.NotFound
90+
91+
// This test shows the current behavior where requesting a resource
92+
// that doesn't exist twice in a row causes calling the version artifact
93+
// twice.
94+
// Fix in scope of https://github.com/typesafegithub/github-workflows-kt/issues/2160
95+
verify(exactly = 2) { mockBuildVersionArtifacts(any(), any()) }
96+
}
97+
}
98+
6799
test("when binding generation fails") {
68100
testApplication {
69101
// Given

0 commit comments

Comments
 (0)