forked from basecamp/fizzy-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathidentity_service_test.go
More file actions
49 lines (43 loc) · 1.47 KB
/
Copy pathidentity_service_test.go
File metadata and controls
49 lines (43 loc) · 1.47 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package fizzy
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"github.com/basecamp/fizzy-sdk/go/pkg/generated"
)
func TestIdentityUpdateTimezone(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPatch {
t.Fatalf("method = %s, want PATCH", r.Method)
}
if r.URL.Path != "/999/my/timezone.json" {
t.Fatalf("path = %s, want /999/my/timezone.json", r.URL.Path)
}
w.WriteHeader(http.StatusNoContent)
}))
defer server.Close()
client := NewClient(&Config{BaseURL: server.URL}, &StaticTokenProvider{Token: "test"})
_, err := client.Identity().UpdateTimezone(context.Background(), "999", &generated.UpdateMyTimezoneRequest{TimezoneName: "America/New_York"})
if err != nil {
t.Fatalf("UpdateTimezone: %v", err)
}
}
func TestPinsListUsesAccountScopedPath(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
t.Fatalf("method = %s, want GET", r.Method)
}
if r.URL.Path != "/999/my/pins.json" {
t.Fatalf("path = %s, want /999/my/pins.json", r.URL.Path)
}
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`[]`))
}))
defer server.Close()
client := NewClient(&Config{BaseURL: server.URL}, &StaticTokenProvider{Token: "test"})
_, _, err := client.ForAccount("999").Pins().List(context.Background())
if err != nil {
t.Fatalf("ListPins: %v", err)
}
}