Skip to content

Commit 7603b45

Browse files
committed
make tests optional (for jitpack)
1 parent 59c3997 commit 7603b45

File tree

12 files changed

+15
-11
lines changed

12 files changed

+15
-11
lines changed

src/commonTest/kotlin/com.adamratzman/spotify/Common.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ val api = when {
1515
}
1616
}.build()
1717
}
18-
else -> {
18+
_clientId != null -> {
1919
spotifyClientApi {
2020
credentials {
2121
clientId = _clientId
@@ -27,6 +27,7 @@ val api = when {
2727
}
2828
}.build()
2929
}
30+
else -> null
3031
}
3132

3233
expect fun getEnvironmentVariable(name: String): String?

src/commonTest/kotlin/com.adamratzman/spotify/pub/BrowseApiTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import org.spekframework.spek2.style.specification.describe
1717

1818
class BrowseApiTest : Spek({
1919
describe("Browse test") {
20-
val b = api.browse
20+
val b = api?.browse ?: return@describe
2121
it("get genre seeds") {
2222
assertTrue(b.getAvailableGenreSeeds().complete().isNotEmpty())
2323
}

src/commonTest/kotlin/com.adamratzman/spotify/pub/PublicAlbumsApiTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import org.spekframework.spek2.style.specification.describe
1515

1616
class PublicAlbumsApiTest : Spek({
1717
describe("Public Albums test") {
18-
val a = api.albums
18+
val a = api?.albums ?: return@describe
1919
describe("get albums") {
2020
it("singular album") {
2121
assertNull(a.getAlbum("asdf", Market.FR).complete())

src/commonTest/kotlin/com.adamratzman/spotify/pub/PublicArtistsApiTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import org.spekframework.spek2.style.specification.describe
1515

1616
class PublicArtistsApiTest : Spek({
1717
describe("Public Artists test") {
18-
val a = api.artists
18+
val a = api?.artists?: return@describe
1919
describe("get artists") {
2020
it("invalid artist") {
2121
assertNull(a.getArtist("adkjlasdf").complete())

src/commonTest/kotlin/com.adamratzman/spotify/pub/PublicFollowingApiTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import org.spekframework.spek2.style.specification.describe
1010

1111
class PublicFollowingApiTest : Spek({
1212
describe("Public Following test") {
13-
val f = api.following
13+
val f = api?.following?: return@describe
1414
describe("do users follow playlist") {
1515
it("invalid users, valid playlist") {
1616
assertFailsWith<SpotifyException.BadRequestException> { f.areFollowingPlaylist("37i9dQZF1DXcBWIGoYBM5M", "udontexist89").complete()[0] }

src/commonTest/kotlin/com.adamratzman/spotify/pub/PublicPlaylistsApiTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import org.spekframework.spek2.style.specification.describe
1414

1515
class PublicPlaylistsApiTest : Spek({
1616
describe("Public playlists test") {
17-
val p = api.playlists
17+
val p = api?.playlists?: return@describe
1818
describe("get user's playlists") {
1919
it("available user should return playlists") {
2020
assertTrue(p.getUserPlaylists("adamratzman1").complete().items.isNotEmpty())

src/commonTest/kotlin/com.adamratzman/spotify/pub/PublicTracksApiTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import org.spekframework.spek2.style.specification.describe
1313

1414
class PublicTracksApiTest : Spek({
1515
describe("Track API (Public View) test") {
16-
val t = api.tracks
16+
val t = api?.tracks?: return@describe
1717
describe("get track") {
1818
it("known track should return author name") {
1919
assertEquals("Bénabar", t.getTrack("5OT3k9lPxI2jkaryRK3Aop").complete()!!.artists[0].name)

src/commonTest/kotlin/com.adamratzman/spotify/pub/PublicUserApiTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.spekframework.spek2.style.specification.describe
1010

1111
class PublicUserApiTest : Spek({
1212
describe("Public User test") {
13+
api?.users ?: return@describe
1314
describe("get user") {
1415
it("available user should return author name") {
1516
assertTrue { catch { api.users.getProfile("adamratzman1").complete()!!.followers.total } != null }

src/commonTest/kotlin/com.adamratzman/spotify/pub/SearchApiTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import org.spekframework.spek2.style.specification.describe
1313

1414
class SearchApiTest : Spek({
1515
describe("Search API test") {
16-
val s = api.search
16+
val s = api?.search ?: return@describe
1717
describe("search multiple") {
1818
it("valid request") {
1919
val query = s.search("lo", *SearchApi.SearchType.values()).complete()

src/commonTest/kotlin/com.adamratzman/spotify/utilities/JsonTests.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import org.spekframework.spek2.style.specification.describe
2222
@UnstableDefault
2323
class JsonTests : Spek({
2424
describe("json serialization tests") {
25+
api?.artists ?: return@describe
26+
2527
it("artist serialization") {
2628
assertTrue(
2729
Json.stringify(

0 commit comments

Comments
 (0)