-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathclient_test.go
34 lines (29 loc) · 880 Bytes
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package anthropic
import (
"net/http"
"testing"
)
func TestWithBetaVersion(t *testing.T) {
t.Run("single beta version", func(t *testing.T) {
opt := withBetaVersion("fake-version")
request, err := http.NewRequest("GET", "http://example.com", nil)
if err != nil {
t.Fatalf("http.NewRequest error: %s", err)
}
opt(request)
if req := request.Header.Get("anthropic-beta"); req != "fake-version" {
t.Errorf("unexpected BetaVersion: %s", req)
}
})
t.Run("multiple beta versions", func(t *testing.T) {
opt := withBetaVersion("fake-version1", "fake-version2")
request, err := http.NewRequest("GET", "http://example.com", nil)
if err != nil {
t.Fatalf("http.NewRequest error: %s", err)
}
opt(request)
if req := request.Header.Get("anthropic-beta"); req != "fake-version1,fake-version2" {
t.Errorf("unexpected BetaVersion: %s", req)
}
})
}