2016-07-27 04:17:04 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/logutils"
|
2022-03-15 12:42:43 +00:00
|
|
|
"github.com/hashicorp/nomad/ci"
|
2016-07-27 04:17:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestLevelFilter(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
2016-07-27 04:17:04 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|