-
Notifications
You must be signed in to change notification settings - Fork 28
/
crm_properties_test.go
81 lines (69 loc) · 1.88 KB
/
crm_properties_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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package hubspot
import (
"fmt"
"os"
"testing"
"time"
)
func TestListCrmProperties(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
// Use crm_schemas:TestCreate() to generate this...
res, err := cli.CRM.Properties.List("cars")
if err != nil {
t.Error(err)
}
if len(res.Results) < 1 {
t.Error("expected len(res.Results) to be > 1")
}
}
func TestGetCrmProperty(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
// Use crm_schemas:TestCreate() to generate this...
res, err := cli.CRM.Properties.Get("cars", "model")
if err != nil {
t.Error(err)
}
if *res.Name != "model" {
t.Errorf("expected res.Name to be model, got %s", res.Name)
}
}
func TestCreateProperty(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
newProp := &CrmProperty{
Name: NewString("mileage"),
Label: NewString("Mileage Label"),
Type: NewString("number"),
FieldType: NewString("number"),
GroupName: NewString("cars_information"),
}
_, err := cli.CRM.Properties.Create("cars", newProp)
if err != nil {
t.Error(err)
return
}
}
func TestUpdateProperty(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
updateProp := make(map[string]interface{})
updateProp["label"] = fmt.Sprintf("Updated Label %s", time.Now().String())
res, err := cli.CRM.Properties.Update("cars", "mileage", &updateProp)
if err != nil {
t.Error(err)
return
}
if res.Label != updateProp["label"] {
t.Errorf("expected res.Label to be %s, got %s", updateProp["label"], res.Label)
}
}
func TestDeleteProperty(t *testing.T) {
t.SkipNow()
cli, _ := NewClient(SetPrivateAppToken(os.Getenv("PRIVATE_APP_TOKEN")))
err := cli.CRM.Properties.Delete("cars", "mileage")
if err != nil {
t.Error(err)
}
}