From 224ebc012910c96947dceb6fa5dd3f9c984ee1b1 Mon Sep 17 00:00:00 2001 From: Kenjiro Nakayama Date: Wed, 27 Jul 2016 13:17:04 +0900 Subject: [PATCH] Add LevelFilter test --- command/agent/log_levels_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 command/agent/log_levels_test.go diff --git a/command/agent/log_levels_test.go b/command/agent/log_levels_test.go new file mode 100644 index 000000000..0a3753a1c --- /dev/null +++ b/command/agent/log_levels_test.go @@ -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) + } + +}