-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeal_test.go
119 lines (106 loc) · 1.96 KB
/
deal_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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package zoho
import (
"fmt"
"log"
"os"
"testing"
)
func TestDeal(t *testing.T) {
id, err := CreateContact(Contact{
Email: "[email protected]",
FirstName: "ForDeal",
LastName: "FORDEAL",
LeadSource: "Test",
})
if err != nil {
panic(err)
}
_, err = CreateDeal(Deal{
DealName: "ForDeal FORDEAL",
Stage: "Prospect",
ContactId: id,
Pipeline: "TEST",
})
if err != nil {
panic(err)
}
/*err = DeleteContact(id)
if err != nil {
panic(err)
}*/
}
// go test -run TestGetDeal
func TestGetDeal(t *testing.T) {
d, err := GetDeal("477339000004063513")
if err != nil {
panic(err)
}
if d.Stage != "Prospect" {
panic(d)
}
}
/*
func TestDoubleDeal(t *testing.T) {
cid, err := FindContact("[email protected]")
if err != nil {
panic(err)
}
did, err := FindDealByContactID(cid)
if err != nil {
panic(err)
}
if did == "" {
panic("deal not found")
}
}
*/
// go test -run TestUpdateStage
func TestUpdateStage(t *testing.T) {
id, err := FindContact("[email protected]")
if err != nil {
panic(err)
}
did, err := FindDealByContactID(id)
if did == "" {
panic("deal not found")
}
if err != nil {
panic(err)
}
err = UpdateDealStage(did, "Meeting")
if err != nil {
panic(err)
}
}
// go test -run TestGetStageHistory
func TestGetStageHistory(t *testing.T) {
h, err := GetDealStageHistory("477339000002064028")
if err != nil {
panic(err)
}
log.Println(h)
}
// go test -run TestGetAllDealIds
func TestGetAllDealIds(t *testing.T) {
ids, err := GetDealIdsFromPipeline("2023-2024")
if err != nil {
panic(err)
}
f, err := os.OpenFile("History 2023-2024.csv", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Println(err)
}
defer f.Close()
for _, id := range ids {
h, err := GetDealStageHistory(id)
if err != nil {
panic(err)
}
fmt.Println(h)
for _, ds := range h {
if _, err := f.WriteString(fmt.Sprintf("%s;%s;%s\r\n", id, ds.Stage, ds.ModifiedTime)); err != nil {
panic(err)
}
}
}
}