Make web service clients context aware

This commit is contained in:
Philipp Wolfer 2025-05-22 09:22:05 +02:00
parent adfe3f5771
commit d1642b7f1f
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
15 changed files with 128 additions and 76 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright © 2023 Philipp Wolfer <phw@uploadedlobster.com>
Copyright © 2023-2025 Philipp Wolfer <phw@uploadedlobster.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -22,6 +22,7 @@ THE SOFTWARE.
package spotify_test
import (
"context"
"net/http"
"testing"
"time"
@ -47,7 +48,8 @@ func TestRecentlyPlayedAfter(t *testing.T) {
"https://api.spotify.com/v1/me/player/recently-played",
"testdata/recently-played.json")
result, err := client.RecentlyPlayedAfter(time.Now(), 3)
ctx := context.Background()
result, err := client.RecentlyPlayedAfter(ctx, time.Now(), 3)
require.NoError(t, err)
assert := assert.New(t)
@ -67,7 +69,8 @@ func TestGetUserTracks(t *testing.T) {
"https://api.spotify.com/v1/me/tracks",
"testdata/user-tracks.json")
result, err := client.UserTracks(0, 2)
ctx := context.Background()
result, err := client.UserTracks(ctx, 0, 2)
require.NoError(t, err)
assert := assert.New(t)