-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgoal_test.go
82 lines (71 loc) · 1.49 KB
/
goal_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
package badsoap
import (
"testing"
)
func TestGoals(t *testing.T) {
a.Testing = t
campaignId, _ := testCampaign("Goals")
defer a.DeleteCampaigns(a.AccountId, []int64{campaignId})
err := a.SetAnalyticsType(a.AccountId, "Enabled")
if err != nil {
t.Fatalf(err.Error())
}
goals := []Goal{
{
Name: "signup",
CostModel: "None",
RevenueModel: RevenueModel{
Type: "None",
},
DaysApplicableForConversion: "Seven",
Steps: []Step{
{
Position: 1,
Name: "Step1",
Type: "Lead",
},
{
Position: 2,
Name: "Step2",
Type: "Browse",
},
{
Position: 3,
Name: "Step3",
Type: "Conversion",
},
},
},
}
goalResults, err := a.AddGoals(a.AccountId, goals)
if err != nil {
t.Fatalf(err.Error())
}
if goalResults == nil {
t.Fatalf("failed to add goal")
}
goals, err = a.GetGoals(a.AccountId)
if err != nil {
t.Fatalf(err.Error())
}
if goals == nil {
t.Fatalf("failed to get goals from account id")
}
goals[0].DaysApplicableForConversion = "Fifteen"
goals[0].Steps[2].Name = "new conversion name"
updatedGoalResults, err := a.UpdateGoals(a.AccountId, goals)
if err != nil {
t.Fatalf(err.Error())
}
if updatedGoalResults == nil {
t.Fatalf("failed to update goals")
}
err = a.SetAnalyticsType(a.AccountId, "Disabled")
if err != nil {
t.Fatalf(err.Error())
}
err = a.DeleteGoals(a.AccountId, []int64{goalResults[0].GoalId})
if err != nil {
t.Fatalf(err.Error())
}
}