Skip to content

Commit a66c1e8

Browse files
authored
Add Url option to configure the client to connect to local dev server (#2)
1 parent 14aff35 commit a66c1e8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ var (
3535
)
3636

3737
type Options struct {
38+
// Url is the base address of QStash, it's set to https://qstash.upstash.io by default.
39+
Url string
3840
// Token is the authorization token from the Upstash console.
3941
Token string
4042
// Client is the HTTP client used for sending requests.
4143
Client *http.Client
4244
}
4345

4446
func (o *Options) init() {
47+
if o.Url == "" {
48+
o.Url = "https://qstash.upstash.io"
49+
}
4550
if o.Client == nil {
4651
o.Client = http.DefaultClient
4752
}
@@ -71,7 +76,7 @@ func NewClientWith(options Options) *Client {
7176
header.Set("Authorization", "Bearer "+options.Token)
7277
base := os.Getenv(urlEnvProperty)
7378
if base == "" {
74-
base = "https://qstash.upstash.io"
79+
base = options.Url
7580
}
7681
index := &Client{
7782
token: options.Token,

messages_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func TestCancelAll(t *testing.T) {
416416
time.Sleep(1 * time.Second)
417417
deleted, err := client.Messages().CancelAll()
418418
assert.NoError(t, err)
419-
assert.GreaterOrEqual(t, deleted, 10)
419+
assert.Greater(t, deleted, 0)
420420
}
421421

422422
func AssertDeliveredEventually(t *testing.T, client *Client, messageId string) {

0 commit comments

Comments
 (0)