mirror of
https://github.com/pischule/memevizor.git
synced 2026-02-04 00:50:52 +00:00
Compare commits
3 Commits
8291c72b0d
...
61a6b6608e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61a6b6608e | ||
| f055a7f82f | |||
| f6c90b071e |
7
.github/workflows/release.yaml
vendored
7
.github/workflows/release.yaml
vendored
@@ -16,12 +16,9 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
- uses: jdx/mise-action@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'gradle'
|
||||
version: 2025.12.12
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
11
.github/workflows/test.yaml
vendored
11
.github/workflows/test.yaml
vendored
@@ -11,13 +11,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
- uses: jdx/mise-action@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
cache: 'gradle'
|
||||
|
||||
version: 2025.12.12
|
||||
- name: Test with Gradle
|
||||
run: ./gradlew check
|
||||
run: mise run test
|
||||
|
||||
@@ -36,6 +36,7 @@ dependencies {
|
||||
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
|
||||
testImplementation("io.kotest:kotest-assertions-core:6.0.7")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
|
||||
1
gradle.properties
Normal file
1
gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
org.gradle.configuration-cache=true
|
||||
@@ -4,3 +4,7 @@ java = "temurin-21"
|
||||
[tasks.fmt]
|
||||
description = 'Fourmat source code'
|
||||
run = './gradlew :spotlessApply'
|
||||
|
||||
[tasks.test]
|
||||
description = 'Run tests'
|
||||
run = './gradlew check'
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.pischule.memevizor.util
|
||||
|
||||
import com.github.kotlintelegrambot.entities.Chat
|
||||
import com.github.kotlintelegrambot.entities.Message
|
||||
import com.github.kotlintelegrambot.entities.files.Document
|
||||
import com.github.kotlintelegrambot.entities.files.PhotoSize
|
||||
import com.github.kotlintelegrambot.entities.files.Video
|
||||
import com.github.kotlintelegrambot.entities.files.VideoNote
|
||||
import io.kotest.matchers.nulls.shouldBeNull
|
||||
import io.kotest.matchers.shouldBe
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class TelegramHelperTest {
|
||||
private val mockChat = Chat(id = 1L, type = "private")
|
||||
|
||||
@Test
|
||||
fun `getMedia should return photo from PhotoSize`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
photo = listOf(PhotoSize("p1", "p1u", 100, 100), PhotoSize("p2", "p2u", 200, 200)),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result shouldBe MessageMedia(fileId = "p2", type = MessageMedia.Type.PHOTO)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return video from Video`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
video = Video("v1", "v1u", 100, 100, 10),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result shouldBe MessageMedia(fileId = "v1", type = MessageMedia.Type.VIDEO)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return video from VideoNote`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
videoNote = VideoNote("vn1", "vn1u", 100, 10),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result shouldBe MessageMedia(fileId = "vn1", type = MessageMedia.Type.VIDEO)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return video from Document with video mimeType`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
document = Document("d1", "d1u", mimeType = "video/mp4"),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result shouldBe MessageMedia(fileId = "d1", type = MessageMedia.Type.VIDEO)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return null for Document with non-video mimeType`() {
|
||||
val message =
|
||||
Message(
|
||||
messageId = 1L,
|
||||
chat = mockChat,
|
||||
date = 123,
|
||||
document = Document("d1", "d1u", mimeType = "image/jpeg"),
|
||||
)
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result.shouldBeNull()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getMedia should return null for message with no media`() {
|
||||
val message = Message(messageId = 1L, chat = mockChat, date = 123, text = "hello")
|
||||
|
||||
val result = message.getMedia()
|
||||
|
||||
result.shouldBeNull()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user