From 10030e02359c061e42892998a7af289592da6e11 Mon Sep 17 00:00:00 2001 From: BartArys Date: Thu, 25 Jun 2020 10:37:43 +0200 Subject: [PATCH] Move invite test to rest, Fix image from binary --- core/src/test/kotlin/InviteTests.kt | 22 ------------------- .../kordlib/rest/services/RestServiceTest.kt | 8 ++++--- 2 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 core/src/test/kotlin/InviteTests.kt diff --git a/core/src/test/kotlin/InviteTests.kt b/core/src/test/kotlin/InviteTests.kt deleted file mode 100644 index a9d802b91346..000000000000 --- a/core/src/test/kotlin/InviteTests.kt +++ /dev/null @@ -1,22 +0,0 @@ -import com.gitlab.kordlib.cache.api.put -import com.gitlab.kordlib.core.Kord -import com.gitlab.kordlib.core.supplier.EntitySupplyStrategy -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.test.runBlockingTest -import org.junit.jupiter.api.BeforeAll -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.TestInstance -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable -import kotlin.test.assertEquals - -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -@EnabledIfEnvironmentVariable(named = "TARGET_BRANCH", matches = "master") -class InviteTests { - - @Test - fun `get invite from rest and cache`() = runBlocking { - val kord = Kord(System.getenv("KORD_TEST_TOKEN")) - val invite = kord.with(EntitySupplyStrategy.rest).getInvite("mpDQm5N") - assertEquals("mpDQm5N", invite.code) - } -} \ No newline at end of file diff --git a/rest/src/test/kotlin/com/gitlab/kordlib/rest/services/RestServiceTest.kt b/rest/src/test/kotlin/com/gitlab/kordlib/rest/services/RestServiceTest.kt index a4e2af859c8e..b60472403653 100644 --- a/rest/src/test/kotlin/com/gitlab/kordlib/rest/services/RestServiceTest.kt +++ b/rest/src/test/kotlin/com/gitlab/kordlib/rest/services/RestServiceTest.kt @@ -22,11 +22,11 @@ fun image(path: String): String { return "data:image/$imageType;base64, $encoded" } -fun imageBinary(path: String) : Image { +fun imageBinary(path: String): Image { val loader = Unit::class.java.classLoader val image = loader?.getResource(path)?.readBytes() val imageType = path.split(".").last() - val format = Image.Format.fromContentType(imageType) + val format = Image.Format.fromContentType("image/$imageType") return Image.raw(image!!, format) } @@ -98,7 +98,9 @@ class RestServiceTest { fun `create invite`() = runBlocking { val generalId = rest.guild.getGuildChannels(guildId).first { it.type == ChannelType.GuildText }.id - rest.channel.createInvite(generalId) + val invite = rest.channel.createInvite(generalId) + + rest.invite.getInvite(invite.code, true) Unit }