forked from PostHog/posthog-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alias_test.go
54 lines (43 loc) · 1.17 KB
/
alias_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
package posthog
import "testing"
func TestAliasMissingDistinctId(t *testing.T) {
alias := Alias{
Alias: "1",
}
if err := alias.Validate(); err == nil {
t.Error("validating an invalid alias object succeeded:", alias)
} else if e, ok := err.(FieldError); !ok {
t.Error("invalid error type returned when validating alias:", err)
} else if e != (FieldError{
Type: "posthog.Alias",
Name: "DistinctId",
Value: "",
}) {
t.Error("invalid error value returned when validating alias:", err)
}
}
func TestAliasMissingAlias(t *testing.T) {
alias := Alias{
DistinctId: "1",
}
if err := alias.Validate(); err == nil {
t.Error("validating an invalid alias object succeeded:", alias)
} else if e, ok := err.(FieldError); !ok {
t.Error("invalid error type returned when validating alias:", err)
} else if e != (FieldError{
Type: "posthog.Alias",
Name: "Alias",
Value: "",
}) {
t.Error("invalid error value returned when validating alias:", err)
}
}
func TestAliasValid(t *testing.T) {
alias := Alias{
Alias: "1",
DistinctId: "2",
}
if err := alias.Validate(); err != nil {
t.Error("validating a valid alias object failed:", alias, err)
}
}