github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/command/agent/log_levels_test.go (about)

     1  package agent
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/hashicorp/logutils"
     7  )
     8  
     9  func TestLevelFilter(t *testing.T) {
    10  	t.Parallel()
    11  
    12  	filt := LevelFilter()
    13  	filt.Levels = []logutils.LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERR"}
    14  	level := logutils.LogLevel("INFO")
    15  
    16  	// LevelFilter regards INFO as valid level
    17  	if !ValidateLevelFilter(level, filt) {
    18  		t.Fatalf("expected valid LogLevel, %s was invalid", level)
    19  	}
    20  
    21  	level = logutils.LogLevel("FOO")
    22  
    23  	// LevelFilter regards FOO as invalid level
    24  	if ValidateLevelFilter(level, filt) {
    25  		t.Fatalf("expected invalid LogLevel, %s was valid", level)
    26  	}
    27  
    28  }