-
Notifications
You must be signed in to change notification settings - Fork 89
/
alias_test.go
54 lines (43 loc) · 1.18 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 analytics
import "testing"
func TestAliasMissingUserId(t *testing.T) {
alias := Alias{
PreviousId: "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: "analytics.Alias",
Name: "UserId",
Value: "",
}) {
t.Error("invalid error value returned when validating alias:", err)
}
}
func TestAliasMissingPreviousId(t *testing.T) {
alias := Alias{
UserId: "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: "analytics.Alias",
Name: "PreviousId",
Value: "",
}) {
t.Error("invalid error value returned when validating alias:", err)
}
}
func TestAliasValid(t *testing.T) {
alias := Alias{
PreviousId: "1",
UserId: "2",
}
if err := alias.Validate(); err != nil {
t.Error("validating a valid alias object failed:", alias, err)
}
}