-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathhal_test.go
47 lines (38 loc) · 954 Bytes
/
hal_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
package dwolla
import (
"testing"
)
func TestLink(t *testing.T) {
var link Link
linkJSON := `
{
"href": "https://api.dwolla.com/customers/123",
"type": "application/json",
"resource-type": "customer"
}`
if err := Unmarshal([]byte(linkJSON), &link); err != nil {
t.Errorf("%v", err)
}
if link.Href != "https://api.dwolla.com/customers/123" {
t.Errorf("Expected https://api.dwolla.com/customers/123, got %s", link.Href)
}
}
func TestResource(t *testing.T) {
var resource Resource
resourceJSON := `
{
"_links": {
"self": {
"href": "https://api.dwolla.com/customers/123",
"type": "application/json",
"resource-type": "customer"
}
}
}`
if err := Unmarshal([]byte(resourceJSON), &resource); err != nil {
t.Errorf("%v", err)
}
if resource.Links["self"].Href != "https://api.dwolla.com/customers/123" {
t.Errorf("Expected https://api.dwolla.com/customers/123, got %s", resource.Links["self"].Href)
}
}