-
Notifications
You must be signed in to change notification settings - Fork 20
/
group_identify_test.go
50 lines (39 loc) · 1.34 KB
/
group_identify_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
package posthog
import "testing"
func TestGroupIdentifyMissingType(t *testing.T) {
groupIdentify := GroupIdentify{}
if err := groupIdentify.Validate(); err == nil {
t.Error("validating an invalid group identify object succeeded:", groupIdentify)
} else if e, ok := err.(FieldError); !ok {
t.Error("invalid error type returned when validating group identify:", err)
} else if e != (FieldError{
Type: "posthog.GroupIdentify",
Name: "Type",
Value: "",
}) {
t.Error("invalid error value returned when validating group identify:", err)
}
}
func TestGroupIdentifyMissingKey(t *testing.T) {
groupIdentify := GroupIdentify{Type: "organization"}
if err := groupIdentify.Validate(); err == nil {
t.Error("validating an invalid group identify object succeeded:", groupIdentify)
} else if e, ok := err.(FieldError); !ok {
t.Error("invalid error type returned when validating group identify:", err)
} else if e != (FieldError{
Type: "posthog.GroupIdentify",
Name: "Key",
Value: "",
}) {
t.Error("invalid error value returned when validating group identify:", err)
}
}
func TestGroupIdentifyValidWithTypeAndKey(t *testing.T) {
groupIdentify := GroupIdentify{
Type: "organization",
Key: "id:5",
}
if err := groupIdentify.Validate(); err != nil {
t.Error("validating a valid identify object failed:", groupIdentify, err)
}
}