Skip to content

Commit 514c38a

Browse files
committed
add platform checker
Signed-off-by: Adam Ratzman <[email protected]>
1 parent bb3c4ec commit 514c38a

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ repositories {
3737
jcenter()
3838
}
3939
40-
implementation("com.adamratzman:spotify-api-kotlin-core:3.3.0")
40+
implementation("com.adamratzman:spotify-api-kotlin-core:3.3.01")
4141
```
4242

4343
Note that images and profiles are not supported on the Kotlin/JS target.

build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies {
3636
}
3737

3838
group = "com.adamratzman"
39-
version = "3.3.0"
39+
version = "3.3.01"
4040

4141
tasks.withType<Test> {
4242
this.testLogging {
@@ -67,6 +67,7 @@ android {
6767
}
6868
}
6969
testOptions {
70+
this.unitTests.isReturnDefaultValues = true
7071
@Suppress("UNCHECKED_CAST")
7172
this.unitTests.all(closureOf<Test> {
7273
// this.useJUnitPlatform()
@@ -216,17 +217,14 @@ kotlin {
216217
}
217218

218219
dependencies {
219-
implementation("net.sourceforge.streamsupport:android-retrofuture:1.7.2")
220220
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
221-
implementation("io.coil-kt:coil:1.1.0")
222221
}
223222
}
224223

225224
val androidTest by getting {
226225
dependencies {
227226
implementation(kotlin("test-junit"))
228227
implementation("com.sparkjava:spark-core:2.9.3")
229-
implementation("org.mockito:mockito-core:3.3.3")
230228
runtimeOnly(kotlin("reflect"))
231229
}
232230
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2020; Original author: Adam Ratzman */
2+
package com.adamratzman.spotify.utils
3+
4+
public actual val platform: Platform = Platform.ANDROID
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2020; Original author: Adam Ratzman */
2+
package com.adamratzman.spotify.utils
3+
4+
public enum class Platform {
5+
JVM,
6+
ANDROID,
7+
JS
8+
}
9+
10+
public expect val platform: Platform

src/commonTest/kotlin/com.adamratzman/spotify/priv/ClientPlaylistApiTest.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import com.adamratzman.spotify.models.Playlist
99
import com.adamratzman.spotify.models.SimplePlaylist
1010
import com.adamratzman.spotify.runBlockingTest
1111
import com.adamratzman.spotify.spotifyApi
12-
import kotlinx.coroutines.CoroutineScope
13-
import kotlinx.coroutines.async
14-
import kotlinx.coroutines.awaitAll
15-
import kotlinx.coroutines.coroutineScope
12+
import com.adamratzman.spotify.utils.Platform
13+
import com.adamratzman.spotify.utils.platform
1614
import kotlin.test.Test
1715
import kotlin.test.assertEquals
1816
import kotlin.test.assertTrue
17+
import kotlinx.coroutines.async
18+
import kotlinx.coroutines.awaitAll
19+
import kotlinx.coroutines.coroutineScope
1920

2021
class ClientPlaylistApiTest {
2122
lateinit var api: SpotifyClientApi
@@ -31,7 +32,7 @@ class ClientPlaylistApiTest {
3132
return ::api.isInitialized
3233
}
3334

34-
private suspend fun CoroutineScope.tearDown() {
35+
private suspend fun tearDown() {
3536
if (::createdPlaylist.isInitialized) {
3637
coroutineScope {
3738
api.playlists.getClientPlaylists().getAllItemsNotNull()
@@ -105,10 +106,12 @@ class ClientPlaylistApiTest {
105106

106107
api.playlists.addTracksToClientPlaylist(createdPlaylist.id, "3WDIhWoRWVcaHdRwMEHkkS", "7FjZU7XFs7P9jHI9Z0yRhK")
107108

108-
api.playlists.uploadClientPlaylistCover(
109-
createdPlaylist.id,
110-
imageUrl = "https://developer.spotify.com/assets/WebAPI_intro.png"
111-
)
109+
if (platform != Platform.ANDROID) {
110+
api.playlists.uploadClientPlaylistCover(
111+
createdPlaylist.id,
112+
imageUrl = "https://developer.spotify.com/assets/WebAPI_intro.png"
113+
)
114+
}
112115

113116
var updatedPlaylist = api.playlists.getClientPlaylist(createdPlaylist.id)!!
114117
val fullPlaylist = updatedPlaylist.toFullPlaylist()!!
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2020; Original author: Adam Ratzman */
2+
package com.adamratzman.spotify.utils
3+
4+
public actual val platform: Platform = Platform.JS
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* Spotify Web API, Kotlin Wrapper; MIT License, 2017-2020; Original author: Adam Ratzman */
2+
package com.adamratzman.spotify.utils
3+
4+
public actual val platform: Platform = Platform.JVM

0 commit comments

Comments
 (0)