Files
nomad/command/agent/log_levels_test.go
James Rasell 753f752cdd agent: remove unused log filter and unrequired library. (#24873)
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.
2025-01-17 07:51:27 +00:00

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))
})
}
}