-
Notifications
You must be signed in to change notification settings - Fork 3
/
closeioClient_test.go
61 lines (44 loc) · 1.3 KB
/
closeioClient_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
package closeio
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_ConvertQuery(t *testing.T) {
query := map[string][]string{
"Custom.Field": []string{"One", "Two", "Three"},
}
queryString := convertQueryFields(query)
expected := `(Custom.Field:"One" OR Custom.Field:"Two" OR Custom.Field:"Three")`
if queryString != expected {
t.Errorf("Expected %s, got %s", expected, queryString)
}
}
func Test_UpdateCustomFields(t *testing.T) {
lead := &Lead{
Name: "Test",
Description: "description",
Custom: map[string]interface{}{
"field1": "value1",
"field2": "value2",
},
}
content, err := LeadToJSON(*lead)
assert.Nil(t, err)
retrieved, err := JSONToLead(content)
assert.Nil(t, err)
assert.EqualValues(t, lead, retrieved)
}
// Test assumes golang maps are ordered, which they aren't
/*func Test_ConvertQuery(t *testing.T) {
query := map[string][]string{
"Status": []string{"Open", "Lost"},
"Town": []string{"Paris"},
"Custom.Field": []string{"One", "Two", "Three"},
}
queryString := convertQueryFields(query)
expected := `(Status:"Open" OR Status:"Lost") AND (Town:"Paris") AND (Custom.Field:"One" OR Custom.Field:"Two" OR Custom.Field:"Three")`
if queryString != expected {
t.Errorf("Expected %s, got %s", expected, queryString)
}
}
*/