Skip to content

Commit c415ed2

Browse files
committed
update testing page
1 parent f67a4e6 commit c415ed2

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

TESTING.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,50 @@
33
We use [Spek](https://github.com/spekframework/spek) to run unit tests. You must add Maven Central to the gradle repositories
44
in order to pull Spek.
55

6+
You must create a Spotify application [here](https://developer.spotify.com/dashboard/applications) to get credentials.
7+
68
To run **only** public endpoint tests, run
79

8-
`gradle test -PclientId=YOUR_CLIENT_ID -PclientSecret=YOUR_CLIENT_SECRET`
10+
`gradle check`
11+
12+
Note: You must have `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET` as environment variables.
913

1014
To run **all** tests, you need a valid Spotify application, redirect uri, and token string. use:
1115

12-
`gradle test -PclientId=YOUR_CLIENT_ID -PclientSecret=YOUR_CLIENT_SECRET -PspotifyRedirectUri=SPOTIFY_REDIRECT_URI -PspotifyTokenString=SPOTIFY_TOKEN`
16+
`gradle check`
17+
18+
Note: In addition to `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET`, you also must have the following environment
19+
variables set up: `SPOTIFY_REDIRECT_URI` and `SPOTIFY_TOKEN_STRING`
1320

1421
Some tests may fail if you do not allow access to all required scopes. To mitigate this, you can individually grant
1522
each scope or use the following code snippet to print out the Spotify token string (given a generated authorization code)
1623

1724
**How to generate an authorization URL**
1825
```kotlin
1926
import com.adamratzman.spotify.main.SpotifyScope
20-
import com.adamratzman.spotify.main.spotifyApi
21-
22-
spotifyApi {
23-
credentials {
24-
clientId = "YOUR_CLIENT_ID"
25-
clientSecret = "YOUR_CLIENT_SECRET"
26-
redirectUri = "YOUR_REDIRECT_URI"
27+
import com.adamratzman.spotify.SpotifyApi.Companion.spotifyClientApi
28+
29+
val api = spotifyClientApi(
30+
"SPOTIFY_CLIENT_ID",
31+
"SPOTIFY_CLIENT_SECRET",
32+
"SPOTIFY_REDIRECT_URI") {
33+
authorization {
34+
tokenString = "SPOTIFY_TOKEN_STRING"
2735
}
2836
}.getAuthorizationUrl(*SpotifyScope.values())
2937

3038
```
3139

3240
**How to get a Spotify token**
3341
```kotlin
34-
import com.adamratzman.spotify.main.spotifyApi
35-
36-
spotifyApi {
37-
credentials {
38-
clientId = "YOUR_CLIENT_ID"
39-
clientSecret = "YOUR_CLIENT_SECRET"
40-
redirectUri = "YOUR_REDIRECT_URI"
41-
}
42-
clientAuthentication {
43-
authorizationCode = "SPOTIFY_AUTHORIZATION_CODE"
42+
import com.adamratzman.spotify.SpotifyApi.Companion.spotifyClientApi
43+
44+
val api = spotifyClientApi(
45+
"SPOTIFY_CLIENT_ID",
46+
"SPOTIFY_CLIENT_SECRET",
47+
"SPOTIFY_REDIRECT_URI") {
48+
authorization {
49+
tokenString = "SPOTIFY_TOKEN_STRING"
4450
}
45-
}.buildClient().token.access_token.let { println(it) }
51+
}.build().token.accessToken.let { println(it) }
4652
```

0 commit comments

Comments
 (0)