Skip to content

Commit 052e126

Browse files
committed
Fix test compilation errors blocking CI
- Add missing testImplementation(libs.junit) to squarescreen-core - Remove baseUrl from SquareScreenConfig in SquareScreenResultTest (field removed) - Fix File.createTempFile prefixes to meet 3-char minimum in MediaFileCacheTest - Update PlayerRepositoryTest: add Playlist.schedule/playlist params, implement reportPlayback/fetchCommands/acknowledgeCommand in FakeNetworkDataSource
1 parent 186461a commit 052e126

4 files changed

Lines changed: 23 additions & 7 deletions

File tree

squarescreen-cache/src/test/kotlin/io/squarescreen/cache/file/MediaFileCacheTest.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.squarescreen.cache.file
22

33
import org.junit.After
44
import org.junit.Assert.assertArrayEquals
5+
import org.junit.Assert.assertEquals
56
import org.junit.Assert.assertNotNull
67
import org.junit.Assert.assertNull
78
import org.junit.Assert.assertTrue
@@ -46,8 +47,8 @@ class MediaFileCacheTest {
4647
@Test
4748
fun sameUrlProducesSameFile() {
4849
val url = "https://cdn.example.com/image.jpg"
49-
val source1 = File.createTempFile("t1", ".jpg").also { it.writeText("first") }
50-
val source2 = File.createTempFile("t2", ".jpg").also { it.writeText("second") }
50+
val source1 = File.createTempFile("tmp1", ".jpg").also { it.writeText("first") }
51+
val source2 = File.createTempFile("tmp2", ".jpg").also { it.writeText("second") }
5152

5253
cache.saveFile(url, source1)
5354
cache.saveFile(url, source2)
@@ -60,8 +61,8 @@ class MediaFileCacheTest {
6061

6162
@Test
6263
fun differentUrlsProduceDifferentFiles() {
63-
val source1 = File.createTempFile("t1", ".jpg").also { it.writeText("image1") }
64-
val source2 = File.createTempFile("t2", ".jpg").also { it.writeText("image2") }
64+
val source1 = File.createTempFile("tmp1", ".jpg").also { it.writeText("image1") }
65+
val source2 = File.createTempFile("tmp2", ".jpg").also { it.writeText("image2") }
6566

6667
cache.saveFile("https://cdn.example.com/a.jpg", source1)
6768
cache.saveFile("https://cdn.example.com/b.jpg", source2)
@@ -74,7 +75,7 @@ class MediaFileCacheTest {
7475

7576
@Test
7677
fun clearAll_removesAllCachedFiles() {
77-
val source = File.createTempFile("t", ".jpg").also { it.writeText("data") }
78+
val source = File.createTempFile("tmp", ".jpg").also { it.writeText("data") }
7879
val url = "https://cdn.example.com/file.jpg"
7980
cache.saveFile(url, source)
8081

squarescreen-core/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ android {
2929
dependencies {
3030
api(libs.kotlinx.serialization.json)
3131
api(libs.kotlinx.coroutines.core)
32+
33+
testImplementation(libs.junit)
3234
}
3335

3436
mavenPublishing {

squarescreen-core/src/test/kotlin/io/squarescreen/core/SquareScreenResultTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class SquareScreenResultTest {
5454
fun `SquareScreenConfig rejects short heartbeat interval`() {
5555
try {
5656
io.squarescreen.core.config.SquareScreenConfig(
57-
baseUrl = "https://api.squarescreen.io",
5857
deviceId = "id",
5958
deviceToken = "token",
6059
heartbeatIntervalSeconds = 10L,

squarescreen-player/src/test/kotlin/io/squarescreen/player/internal/PlayerRepositoryTest.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package io.squarescreen.player.internal
22

33
import io.squarescreen.core.cache.CacheProvider
44
import io.squarescreen.core.datasource.NetworkDataSource
5+
import io.squarescreen.core.model.Command
56
import io.squarescreen.core.model.DeviceStatus
67
import io.squarescreen.core.model.EmergencyAlert
78
import io.squarescreen.core.model.HeartbeatPayload
9+
import io.squarescreen.core.model.PlaybackReport
810
import io.squarescreen.core.model.Playlist
911
import io.squarescreen.core.result.SquareScreenError
1012
import io.squarescreen.core.result.SquareScreenResult
@@ -107,12 +109,14 @@ class PlayerRepositoryTest {
107109
private fun emptyPlaylist(cachedAt: Long) = Playlist(
108110
items = emptyList(),
109111
strategy = null,
112+
schedule = null,
113+
playlist = null,
110114
cachedAt = cachedAt
111115
)
112116

113117
private class FakeNetworkDataSource : NetworkDataSource {
114118
var nowPlayingResult: SquareScreenResult<Playlist> =
115-
SquareScreenResult.Success(Playlist(emptyList(), null, 0L))
119+
SquareScreenResult.Success(Playlist(emptyList(), null, null, null, 0L))
116120
var fetchNowPlayingCallCount = 0
117121

118122
override suspend fun fetchNowPlaying(
@@ -127,6 +131,16 @@ class PlayerRepositoryTest {
127131

128132
override suspend fun fetchEmergencyAlert(): SquareScreenResult<EmergencyAlert?> =
129133
SquareScreenResult.Success(null)
134+
135+
override suspend fun reportPlayback(report: PlaybackReport): SquareScreenResult<Unit> =
136+
SquareScreenResult.Success(Unit)
137+
138+
override suspend fun fetchCommands(): SquareScreenResult<List<Command>> =
139+
SquareScreenResult.Success(emptyList())
140+
141+
override suspend fun acknowledgeCommand(
142+
commandId: String, status: String, result: Map<String, String>
143+
): SquareScreenResult<Unit> = SquareScreenResult.Success(Unit)
130144
}
131145

132146
private class FakeCacheProvider : CacheProvider {

0 commit comments

Comments
 (0)