-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates the server discovery test to correctly check if a server is found or not from a Broadcast message.
- Loading branch information
1 parent
a701ca4
commit 06f8a76
Showing
5 changed files
with
39 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 17 additions & 2 deletions
19
emby-lib/src/test/kotlin/us/nineworlds/serenity/emby/server/EmbyServerDiscoverTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
package us.nineworlds.serenity.emby.server | ||
|
||
import app.cash.turbine.turbineScope | ||
import assertk.assertThat | ||
import assertk.assertions.isEqualTo | ||
import kotlinx.coroutines.flow.distinctUntilChanged | ||
import kotlinx.coroutines.test.runTest | ||
import org.junit.Assert.* | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.shadows.ShadowLog | ||
import timber.log.Timber | ||
import us.nineworlds.serenity.common.channels.ServerChannel | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class EmbyServerDiscoverTest { | ||
|
||
private lateinit var serverDiscovery : EmbyServerDiscover | ||
|
||
@Before | ||
fun setUp() { | ||
Timber.plant(Timber.DebugTree()) | ||
ShadowLog.stream = System.out | ||
serverDiscovery = EmbyServerDiscover() | ||
} | ||
|
||
@Test | ||
fun `discover any known servers`() = runTest { | ||
serverDiscovery.findServers() | ||
turbineScope { | ||
val servers = ServerChannel.serverEvents.distinctUntilChanged().testIn(backgroundScope) | ||
serverDiscovery.findServers() | ||
val serverItem = servers.awaitItem() | ||
assertThat(serverItem.serverName).isEqualTo("Emby - Emby Server") | ||
servers.cancelAndIgnoreRemainingEvents() | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters