Merge pull request #1470 from nak3/add-log_levels_test
Add LevelFilter test
This commit is contained in:
commit
d0e82f2c7f
27
command/agent/log_levels_test.go
Normal file
27
command/agent/log_levels_test.go
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package agent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/logutils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLevelFilter(t *testing.T) {
|
||||||
|
|
||||||
|
filt := LevelFilter()
|
||||||
|
filt.Levels = []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERR"}
|
||||||
|
level := logutils.LogLevel("INFO")
|
||||||
|
|
||||||
|
// LevelFilter regards INFO as valid level
|
||||||
|
if !ValidateLevelFilter(level, filt) {
|
||||||
|
t.Fatalf("expected valid LogLevel, %s was invalid", level)
|
||||||
|
}
|
||||||
|
|
||||||
|
level = logutils.LogLevel("FOO")
|
||||||
|
|
||||||
|
// LevelFilter regards FOO as invalid level
|
||||||
|
if ValidateLevelFilter(level, filt) {
|
||||||
|
t.Fatalf("expected invalid LogLevel, %s was valid", level)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue