Skip to content

Commit 7d24ad8

Browse files
committed
FEAT: updated Spotify module to version 0.2.1 (test file moved to the test folder)
1 parent 1b74d4d commit 7d24ad8

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/modules/spotify.reb

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Rebol [
22
Title: "Spotify"
33
Purpose: "Spotify Web API access"
4-
Version: 0.2.0
4+
Version: 0.2.1
55
Author: @Oldes
66
Date: 20-Jul-2023
77
File: %spotify.reb
@@ -267,13 +267,16 @@ refresh: function[
267267
])
268268
]
269269
data: attempt [load-json result/3]
270-
either result/1 >= 400 [
270+
if result/1 >= 400 [
271271
sys/log/error 'SPOTIFY "Failed to refresh access token!"
272272
if data/error_description [ sys/log/error 'SPOTIFY data/error_description ]
273-
none
274-
][
275-
ctx/token: data
273+
return none
276274
]
275+
try/with [
276+
data/expires_in: now + (to time! data/expires_in)
277+
ctx/token: data
278+
store-config ctx
279+
] :print
277280
]
278281

279282
request: func [

src/modules/spotify-test.r3 src/tests/test-spotify.r3

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Rebol [
22
Title: "Test Spotify module"
3-
Version: 0.2.0
3+
Version: 0.2.1
44
Author: @Oldes
55
Date: 20-Jul-2023
66
File: %test-spotify.r3
@@ -11,17 +11,20 @@ system/options/quiet: false ;; allow Spotify traces
1111
system/options/log/spotify: 4 ;; verbose
1212
system/options/log/http: 0 ;; no HTTP traces
1313

14-
;; make sure that we load a fresh extension
15-
try [system/modules/spotify: none]
16-
spotify: import %spotify.reb
14+
spotify: import spotify
1715

1816
test-all?: false ;; I don't want CI tests to stop my real playback
1917

18+
errors: 0 ;; error counter (process return value)
19+
2020
do-test: func[title code][
2121
print-horizontal-line
2222
print as-yellow title
2323
probe code
24-
try/with code :print
24+
try/with code [
25+
print system/state/last-error
26+
++ errors
27+
]
2528
]
2629

2730

@@ -182,3 +185,5 @@ if test-all? [
182185
probe spotify/put %me/player/seek?position_ms=0
183186
]
184187
]
188+
189+
quit/return errors

0 commit comments

Comments
 (0)