mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
The Nomad agent used a log filter to ensure logs were written at the expected level. Since the use of hclog this is not required, as hclog acts as the gate keeper and filter for logging. All log writers accept messages from hclog which has already done the filtering.
64 lines
1.1 KiB
Go
64 lines
1.1 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package agent
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/nomad/ci"
|
|
"github.com/shoenig/test/must"
|
|
)
|
|
|
|
func Test_isLogLevelValid(t *testing.T) {
|
|
ci.Parallel(t)
|
|
|
|
testCases := []struct {
|
|
name string
|
|
inputLevel string
|
|
expectedOutput bool
|
|
}{
|
|
{
|
|
name: "trace",
|
|
inputLevel: "TRACE",
|
|
expectedOutput: true,
|
|
},
|
|
{
|
|
name: "debug",
|
|
inputLevel: "DEBUG",
|
|
expectedOutput: true,
|
|
},
|
|
{
|
|
name: "info",
|
|
inputLevel: "INFO",
|
|
expectedOutput: true,
|
|
},
|
|
{
|
|
name: "warn",
|
|
inputLevel: "WARN",
|
|
expectedOutput: true,
|
|
},
|
|
{
|
|
name: "error",
|
|
inputLevel: "ERROR",
|
|
expectedOutput: true,
|
|
},
|
|
{
|
|
name: "off",
|
|
inputLevel: "OFF",
|
|
expectedOutput: true,
|
|
},
|
|
{
|
|
name: "invalid",
|
|
inputLevel: "INVALID",
|
|
expectedOutput: false,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
must.Eq(t, tc.expectedOutput, isLogLevelValid(tc.inputLevel))
|
|
})
|
|
}
|
|
}
|