Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
added test cases for invalid input and for max log values
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrod1598 committed Mar 3, 2021
1 parent 14a53ea commit ef9d6c0
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 0 deletions.
70 changes: 70 additions & 0 deletions operator/builtin/input/file/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ func TestConfig(t *testing.T) {
return cfg
}(),
},
{
"include_invalid",
true,
func() *InputConfig {
cfg := defaultCfg()
return cfg
}(),
},
{
"exclude_one",
false,
Expand Down Expand Up @@ -120,6 +128,15 @@ func TestConfig(t *testing.T) {
return cfg
}(),
},
{
"exclude_invalid",
true,
func() *InputConfig {
cfg := defaultCfg()
cfg.Include = append(cfg.Include, "*.log")
return cfg
}(),
},
{
"poll_interval_no_units",
false,
Expand Down Expand Up @@ -201,6 +218,15 @@ func TestConfig(t *testing.T) {
return cfg
}(),
},
{
"fingerprint_size_float",
false,
func() *InputConfig {
cfg := defaultCfg()
cfg.FingerprintSize = helper.ByteSize(1100)
return cfg
}(),
},
{
"include_file_name_lower",
false,
Expand Down Expand Up @@ -405,6 +431,50 @@ func TestConfig(t *testing.T) {
return cfg
}(),
},
{
"max_logs_mib_lower",
false,
func() *InputConfig {
cfg := defaultCfg()
cfg.MaxLogSize = helper.ByteSize(1048576)
return cfg
}(),
},
{
"max_logs_mib_upper",
false,
func() *InputConfig {
cfg := defaultCfg()
cfg.MaxLogSize = helper.ByteSize(1048576)
return cfg
}(),
},
{
"max_logs_mb_upper",
false,
func() *InputConfig {
cfg := defaultCfg()
cfg.MaxLogSize = helper.ByteSize(1048576)
return cfg
}(),
},
{
"max_logs_mb_upper",
false,
func() *InputConfig {
cfg := defaultCfg()
cfg.MaxLogSize = helper.ByteSize(1048576)
return cfg
}(),
},
{
"max_logs_invalid_unit",
true,
func() *InputConfig {
cfg := defaultCfg()
return cfg
}(),
},
}

for _, tc := range cases {
Expand Down
2 changes: 2 additions & 0 deletions operator/builtin/input/file/testdata/encoding_lower.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type: file_input
fingerprint_size: "utf-16le"
2 changes: 2 additions & 0 deletions operator/builtin/input/file/testdata/encoding_upper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type: file_input
fingerprint_size: "UTF-16lE"
4 changes: 4 additions & 0 deletions operator/builtin/input/file/testdata/exclude_invalid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type: file_input
include:
- "*.log"
exclude: "aRandomString"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type: file_input
fingerprint_size: 1.1kb
2 changes: 2 additions & 0 deletions operator/builtin/input/file/testdata/include_invalid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type: file_input
include: "justwords"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type: file_input
max_log_size: 1TOFU
2 changes: 2 additions & 0 deletions operator/builtin/input/file/testdata/max_logs_mb_lower.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type: file_input
max_log_size: 1mib
2 changes: 2 additions & 0 deletions operator/builtin/input/file/testdata/max_logs_mb_upper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type: file_input
max_log_size: 1MiB
2 changes: 2 additions & 0 deletions operator/builtin/input/file/testdata/max_logs_mib_lower.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type: file_input
max_log_size: 1mib
2 changes: 2 additions & 0 deletions operator/builtin/input/file/testdata/max_logs_mib_upper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type: file_input
max_log_size: 1MiB

0 comments on commit ef9d6c0

Please sign in to comment.