forked from segmentio/analytics-go
-
Notifications
You must be signed in to change notification settings - Fork 2
/
config_test.go
46 lines (35 loc) · 1.07 KB
/
config_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
package analytics
import (
"testing"
"time"
)
func TestConfigZeroValue(t *testing.T) {
c := Config{}
if err := c.validate(); err != nil {
t.Error("validating the zero-value configuration failed:", err)
}
}
func TestConfigInvalidInterval(t *testing.T) {
c := Config{
Interval: -1 * time.Second,
}
if err := c.validate(); err == nil {
t.Error("no error returned when validating a malformed config")
} else if e, ok := err.(ConfigError); !ok {
t.Error("invalid error returned when checking a malformed config:", err)
} else if e.Field != "Interval" || e.Value.(time.Duration) != (-1*time.Second) {
t.Error("invalid field error reported:", e)
}
}
func TestConfigInvalidBatchSize(t *testing.T) {
c := Config{
BatchSize: -1,
}
if err := c.validate(); err == nil {
t.Error("no error returned when validating a malformed config")
} else if e, ok := err.(ConfigError); !ok {
t.Error("invalid error returned when checking a malformed config:", err)
} else if e.Field != "BatchSize" || e.Value.(int) != -1 {
t.Error("invalid field error reported:", e)
}
}