mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-21 05:52:35 +08:00
test(jetbrains): cover malformed CLI checksums
This commit is contained in:
+1
@@ -4,6 +4,7 @@ import com.intellij.openapi.util.SystemInfo
|
||||
import com.intellij.util.system.CpuArch
|
||||
|
||||
internal object KiloCliPlatform {
|
||||
// Keep supported OS/architecture pairs in sync with Gradle CLI staging task platform lists.
|
||||
fun current(): String {
|
||||
val os = when {
|
||||
SystemInfo.isMac -> "darwin"
|
||||
|
||||
+27
@@ -118,6 +118,33 @@ class KiloCliDownloaderTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `falls back to github metadata when bundled checksum is malformed`() = runBlocking {
|
||||
MockWebServer().use { server ->
|
||||
val bytes = archive()
|
||||
server.enqueue(metadata(bytes))
|
||||
server.enqueue(MockResponse().setResponseCode(200).setBody(Buffer().write(bytes)))
|
||||
val log = TestLog()
|
||||
|
||||
val cli = KiloCliDownloader(
|
||||
log = log,
|
||||
root = dir,
|
||||
baseUrl = server.url("/release").toString(),
|
||||
api = server.url("/api").toString(),
|
||||
digests = mapOf(KiloCliPlatform.current() to "not-a-digest"),
|
||||
).resolve("1.2.3")
|
||||
|
||||
assertTrue(cli.isFile)
|
||||
assertContains(
|
||||
log.messages,
|
||||
"WARN: Ignoring malformed bundled Kilo CLI checksum for ${KiloCliPlatform.current()}: not-a-digest"
|
||||
)
|
||||
assertEquals("/api/v1.2.3", server.takeRequest().path)
|
||||
assertEquals("/release/v1.2.3/kilo-${KiloCliPlatform.current()}.${KiloCliPlatform.archive()}", server.takeRequest().path)
|
||||
assertEquals(2, server.requestCount)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `prunes stale versions and removes the extracted archive`() = runBlocking {
|
||||
MockWebServer().use { server ->
|
||||
|
||||
@@ -20,6 +20,7 @@ abstract class WriteCliChecksumsTask : DefaultTask() {
|
||||
private val DIGEST = Regex("^sha256:[a-f0-9]{64}$")
|
||||
private val JSON = Json { ignoreUnknownKeys = true }
|
||||
private const val API = "https://api.github.com/repos/Kilo-Org/kilocode/releases/tags"
|
||||
// Keep in sync with KiloCliPlatform.current() and StageBundledCliTask.PLATFORMS.
|
||||
private val PLATFORMS = listOf(
|
||||
"darwin-arm64",
|
||||
"darwin-x64",
|
||||
|
||||
Reference in New Issue
Block a user