-
Notifications
You must be signed in to change notification settings - Fork 6
/
files_test.go
53 lines (42 loc) · 899 Bytes
/
files_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
package invoiced
import (
"encoding/json"
"testing"
)
func TestUnMarshalFileObject(t *testing.T) {
s := `{
"id": 13,
"object": "file",
"name": "logo-invoice.png",
"size": 6936,
"type": "image/png",
"url": "https://invoiced.com/img/logo-invoice.png",
"created_at": 1464625855
}`
so := new(File)
err := json.Unmarshal([]byte(s), so)
if err != nil {
t.Fatal(err)
}
if so.Id != 13 {
t.Fatal("File has incorrect id")
}
if so.Object != "file" {
t.Fatal("File has incorrect object")
}
if so.Name != "logo-invoice.png" {
t.Fatal("File has incorrect logo")
}
if so.Size != 6936 {
t.Fatal("File has incorrect size")
}
if so.Type != "image/png" {
t.Fatal("File has incorrect type")
}
if so.Url != "https://invoiced.com/img/logo-invoice.png" {
t.Fatal("File url is incorrect")
}
if so.CreatedAt != 1464625855 {
t.Fatal("CreatedAt is incorrect")
}
}