-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconfig_test.go
More file actions
129 lines (104 loc) · 3 KB
/
config_test.go
File metadata and controls
129 lines (104 loc) · 3 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidateGroup_valid_chars(t *testing.T) {
err := validateGroup("_-/.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
assert.Nil(t, err)
}
func TestValidateGroup_too_long(t *testing.T) {
err := validateGroup(RandomString(518))
assert.Equal(t, err, errNameTooLong)
}
func TestValidateGroup_empty(t *testing.T) {
err := validateGroup("")
assert.Equal(t, errEmptyValue, err)
}
func TestValidateGroup_invalid_strings(t *testing.T) {
for _, chr := range []string{",", "|", "ą"} {
err := validateGroup(chr)
assert.Equal(t, err, errInvalidValue)
}
}
func TestValidateStream_too_long(t *testing.T) {
err := validateStrean(RandomString(518))
assert.Equal(t, err, errNameTooLong)
}
func TestValidateStream_empty(t *testing.T) {
err := validateStrean("")
assert.Equal(t, errEmptyValue, err)
}
func TestValidateStream_invalid_strings(t *testing.T) {
err := validateGroup(":")
assert.Equal(t, err, errInvalidValue)
}
func TestValidateSource_ok(t *testing.T) {
for _, uri := range []string{
"udp://localhost:5514",
} {
err := validateSource(uri)
assert.Nil(t, err)
}
}
func TestValidateSource_error(t *testing.T) {
for uri, expected := range map[string]error{
"tcp://localhost:5514": errInvalidScheme,
} {
err := validateSource(uri)
assert.Equal(t, err, expected)
}
}
func Test_validateSyslogFormat_empty(t *testing.T) {
err := validateSyslogFormat("")
assert.Equal(t, errEmptyValue, err)
}
func Test_validateSyslogFormat_format(t *testing.T) {
err := validateSyslogFormat("bad_format")
assert.Equal(t, errInvalidFormat, err)
}
func Test_validateCloudwatchFormat_empty(t *testing.T) {
err := validateCloudwatchFormat("")
assert.Equal(t, errEmptyValue, err)
}
func Test_validateLogOutput_empty(t *testing.T) {
err := validateLogOutput("")
assert.Equal(t, errEmptyValue, err)
}
func Test_validateLogLevel_empty(t *testing.T) {
err := validateLogLevel("")
assert.Equal(t, errEmptyValue, err)
}
func Test_validateLogOutput_invalid(t *testing.T) {
err := validateLogOutput("invalid")
assert.Equal(t, errInvalidValue, err)
}
func Test_validateLogLevel_invalid(t *testing.T) {
err := validateLogLevel("invalid")
assert.Equal(t, errInvalidValue, err)
}
func Test_validateLogLevel_ok(t *testing.T) {
for _, option := range validLevelOptions {
assert.Nil(t, validateLogLevel(option))
}
}
func Test_validateLogOutput_ok(t *testing.T) {
for _, option := range validOutputOptions {
assert.Nil(t, validateLogOutput(option))
}
}
func Test_validateStrContains_false(t *testing.T) {
assert.False(t, strIn([]string{}, "needle"))
}
func Test_validateStrContains_true(t *testing.T) {
assert.True(t, strIn([]string{"needle"}, "needle"))
}
func Test_validateUploadDelay_ok(t *testing.T) {
assert.Nil(t, validateUploadDelay(300))
}
func Test_validateUploadDelay_too_small(t *testing.T) {
assert.Equal(t, errTooSmall, validateUploadDelay(1))
}
func Test_validateQueueSize_ok(t *testing.T) {
assert.Nil(t, validateQueueSize(0))
}