-
Notifications
You must be signed in to change notification settings - Fork 3
/
metrics_customer_activities_test.go
57 lines (52 loc) · 1.46 KB
/
metrics_customer_activities_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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package chartmogul
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/davecgh/go-spew/spew"
)
// Test list activities tests.
func TestListCustomerActivities(t *testing.T) {
server := httptest.NewServer(
http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
t.Errorf("Unexpected method %v", r.Method)
}
if r.RequestURI != "/v/customers/cus_8bc55ab6-c3b5-11eb-ac45-2f9a49d75af7/activities" {
t.Errorf("Unexpected URI %v", r.RequestURI)
}
w.WriteHeader(http.StatusOK)
//nolint
w.Write([]byte(`{"entries": [{
"activity-arr": 24000,
"activity-mrr": 2000,
"activity-mrr-movement": 2000,
"currency": "USD",
"currency-sign": "$",
"date": "2015-06-09T13:16:00+00:00",
"description": "purchased the Silver Monthly plan (1)",
"id": 48730,
"type": "new_biz",
"subscription-external-id": "1"
}],
"has_more": false,
"per_page": 200,
"page": 1}`))
}))
defer server.Close()
SetURL(server.URL + "/v/%v")
var tested IApi = &API{
ApiKey: "token",
}
activities, err := tested.MetricsListCustomerActivities(&Cursor{}, "cus_8bc55ab6-c3b5-11eb-ac45-2f9a49d75af7")
if err != nil {
spew.Dump(err)
t.Fatal("Not expected to fail")
}
if len(activities.Entries) == 0 ||
activities.Entries[0].Date != "2015-06-09T13:16:00+00:00" {
spew.Dump(activities)
t.Fatal("Unexpected result")
}
}