mirror of
https://git.sr.ht/~phw/scotty
synced 2025-06-05 12:58:33 +02:00
Make web service clients context aware
This commit is contained in:
parent
adfe3f5771
commit
d1642b7f1f
15 changed files with 128 additions and 76 deletions
|
@ -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 maloja_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
|
@ -48,7 +49,8 @@ func TestGetScrobbles(t *testing.T) {
|
|||
"https://maloja.example.com/apis/mlj_1/scrobbles",
|
||||
"testdata/scrobbles.json")
|
||||
|
||||
result, err := client.GetScrobbles(0, 2)
|
||||
ctx := context.Background()
|
||||
result, err := client.GetScrobbles(ctx, 0, 2)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert := assert.New(t)
|
||||
|
@ -69,12 +71,13 @@ func TestNewScrobble(t *testing.T) {
|
|||
url := server + "/apis/mlj_1/newscrobble"
|
||||
httpmock.RegisterResponder("POST", url, responder)
|
||||
|
||||
ctx := context.Background()
|
||||
scrobble := maloja.NewScrobble{
|
||||
Title: "Oweynagat",
|
||||
Artist: "Dool",
|
||||
Time: 1699574369,
|
||||
}
|
||||
result, err := client.NewScrobble(scrobble)
|
||||
result, err := client.NewScrobble(ctx, scrobble)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "success", result.Status)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue