-
Notifications
You must be signed in to change notification settings - Fork 1
/
notifications_test.go
58 lines (47 loc) · 1.29 KB
/
notifications_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
58
package vscale
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestNotificationsSettingsGet(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/billing/notify", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
response := `{"notify_balance": 0, "status": "ok"}`
fmt.Fprint(w, response)
})
notify, _, err := client.Notifications.Get()
if err != nil {
t.Errorf("Notifications.Get returns error: %v", err)
}
expected := &NotificationsSettings{
NotifyBalance: 0,
Status: "ok",
}
if !reflect.DeepEqual(notify, expected) {
t.Errorf("Notifications.Get returned %+v, expected %+v", notify, expected)
}
}
func TestSetNotifyBalance(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/billing/notify", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
response := `{"notify_balance": 10000, "status": "ok"}`
fmt.Fprint(w, response)
})
notify, _, err := client.Notifications.SetNotifyBalance(10000)
if err != nil {
t.Errorf("Notifications.SetNotifyBalance returns error: %v", err)
}
expected := &NotificationsSettings{
NotifyBalance: 10000,
Status: "ok",
}
if !reflect.DeepEqual(notify, expected) {
t.Errorf("Notifications.SetNotifyBalance returned %+v, expected %+v", notify, expected)
}
}