-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfactory_test.go
More file actions
59 lines (53 loc) · 1.43 KB
/
factory_test.go
File metadata and controls
59 lines (53 loc) · 1.43 KB
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
package drain
import (
"fmt"
"reflect"
"testing"
)
func TestGetUsingInvalidValues(t *testing.T) {
drainStrs := []string{"bogus"}
for _, drainStr := range drainStrs {
_, err := NewDrain(drainStr)
if err == nil || err.Error() != fmt.Sprintf("Cannot construct a drain for URL: '%s'", drainStr) {
t.Error("Did not receive expected error message")
}
}
}
func TestGetUsingEmptyString(t *testing.T) {
d, err := NewDrain("")
if err != nil {
t.Error(err)
}
// Should return nil by default. nil means no drain-- which is valid.
if d != nil {
dType := reflect.TypeOf(d).String()
t.Errorf("Expected a nil drain, but got a %s", dType)
}
}
func TestGetUdpDrain(t *testing.T) {
d, err := NewDrain("udp://my-awesome-log-server:514")
if err != nil {
t.Error(err)
}
if want, got := "*simple.logDrain", reflect.TypeOf(d).String(); want != got {
t.Errorf("Expected a %s, but got a %s", want, got)
}
}
func TestGetSyslogDrain(t *testing.T) {
d, err := NewDrain("syslog://my-awesome-log-server:514")
if err != nil {
t.Error(err)
}
if want, got := "*simple.logDrain", reflect.TypeOf(d).String(); want != got {
t.Errorf("Expected a %s, but got a %s", want, got)
}
}
func TestGetTcpDrain(t *testing.T) {
d, err := NewDrain("tcp://my-awesome-log-server:12345")
if err != nil {
t.Error(err)
}
if want, got := "*simple.logDrain", reflect.TypeOf(d).String(); want != got {
t.Errorf("Expected a %s, but got a %s", want, got)
}
}