-
Notifications
You must be signed in to change notification settings - Fork 5
/
customfields_test.go
49 lines (42 loc) · 1005 Bytes
/
customfields_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
package asana
import (
"encoding/json"
"testing"
)
func TestCustomFieldBase_Precision_ParseZero(t *testing.T) {
cf := &CustomFieldBase{}
if err := json.Unmarshal([]byte(`
{
"precision": 0
}
`), cf); err != nil {
t.Fatal(err)
}
if cf.Precision == nil || *cf.Precision != 0 {
t.Errorf("Expected Precision to be a pointer to the integer zero, but saw %v", cf.Precision)
}
}
func TestCustomFieldBase_Precision_ParseMissing(t *testing.T) {
cf := &CustomFieldBase{}
if err := json.Unmarshal([]byte(`
{
"name": "name"
}
`), cf); err != nil {
t.Fatal(err)
}
if cf.Precision != nil {
t.Errorf("Expected Precision to be a nil, but saw %v", cf.Precision)
}
}
func TestCustomFieldBase_Precision_SerializeZero(t *testing.T) {
val := 0
cf := &CustomFieldBase{Precision: &val}
if bs, err := json.Marshal(cf); err != nil {
t.Fatal(err)
} else {
if string(bs) != `{"precision":0,"resource_subtype":""}` {
t.Errorf("Expected Precision to be a zero, but saw %v", string(bs))
}
}
}