Cotton code
31 lines · 1.4 KB · KotlinRaw
package com.cottondb.downloadsimport com.cottondb.shell.Groundimport org.json.JSONObjectimport org.junit.Assert.assertEqualsimport org.junit.Testimport java.io.Fileclass DownloadsFlavourTest {    private val repo = generateSequence(File("").absoluteFile) { it.parentFile }.first { File(it, "apps/registry.json").isFile }    private fun json(path: String) = JSONObject(File(repo, path).readText())    /** The app stands on the ground its iOS flavour.json names (checker), and its window shows that ground's colour before the first frame. */    @Test    fun downloads_stands_on_the_checker_floor() {        val ground = json("apps/cotton/App/Flavours/downloads/flavour.json").getString("ground")        assertEquals(Ground.of(ground), DownloadsParts().ground)        val window = json("apps/android/app/flavours.json").getJSONObject("downloads").getString("windowGround")        val colour = Ground.checker.colour        fun hex(channel: Float) = "%02X".format((channel * 255).toInt())        assertEquals("#" + hex(colour.red) + hex(colour.green) + hex(colour.blue), window)    }    /** The flavour's kit is the downloads kit, whose one tool the fan opens on. */    @Test    fun downloads_opens_on_its_queue() {        val flavour = json("apps/cotton/App/Flavours/downloads/flavour.json")        assertEquals("downloads", flavour.getString("kit"))        assertEquals("downloads", flavour.getJSONObject("fan").getString("opens"))    }}