From 2b3911eca853ef384b381f57bd09c81b3cb5362b Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Tue, 19 Apr 2022 13:19:47 +0200 Subject: [PATCH] Fix ServerVersion comparison failing when build is not set (#381) --- .../commonMain/kotlin/org/jellyfin/sdk/model/ServerVersion.kt | 2 +- .../org/jellyfin/sdk/model/discovery/ServerVersionTests.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jellyfin-model/src/commonMain/kotlin/org/jellyfin/sdk/model/ServerVersion.kt b/jellyfin-model/src/commonMain/kotlin/org/jellyfin/sdk/model/ServerVersion.kt index a4cb95e34..c0fd6abc2 100644 --- a/jellyfin-model/src/commonMain/kotlin/org/jellyfin/sdk/model/ServerVersion.kt +++ b/jellyfin-model/src/commonMain/kotlin/org/jellyfin/sdk/model/ServerVersion.kt @@ -34,7 +34,7 @@ public data class ServerVersion( { it.major }, { it.minor }, { it.patch }, - { it.build ?: -1 } + { it.build ?: 0 } ) /** diff --git a/jellyfin-model/src/commonTest/kotlin/org/jellyfin/sdk/model/discovery/ServerVersionTests.kt b/jellyfin-model/src/commonTest/kotlin/org/jellyfin/sdk/model/discovery/ServerVersionTests.kt index e2de6b44b..b63a9548c 100644 --- a/jellyfin-model/src/commonTest/kotlin/org/jellyfin/sdk/model/discovery/ServerVersionTests.kt +++ b/jellyfin-model/src/commonTest/kotlin/org/jellyfin/sdk/model/discovery/ServerVersionTests.kt @@ -3,6 +3,7 @@ package org.jellyfin.sdk.model.discovery import org.jellyfin.sdk.model.ServerVersion import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertFalse import kotlin.test.assertNull import kotlin.test.assertTrue @@ -39,5 +40,8 @@ class ServerVersionTests { assertTrue { ServerVersion(1, 2, 3) > ServerVersion(0, 0, 0) } assertTrue { ServerVersion(1, 7, 0, 1) > ServerVersion(1, 7, 0) } + + assertFalse { ServerVersion.fromString("10.8.0")!! < ServerVersion(10, 8, 0, 0) } + assertFalse { ServerVersion.fromString("10.8.0")!! < ServerVersion.fromString("10.8.0")!! } } }