databricks-cli/libs/flags/log_level_flag_test.go

30 lines
670 B
Go
Raw Normal View History

package flags
import (
"testing"
"github.com/databricks/cli/libs/log"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestLogLevelFlagDefault(t *testing.T) {
f := NewLogLevelFlag()
assert.Equal(t, log.LevelDisabled, f.Level())
assert.Equal(t, "disabled", f.String())
}
func TestLogLevelFlagSetValid(t *testing.T) {
f := NewLogLevelFlag()
err := f.Set("info")
require.NoError(t, err)
assert.Equal(t, log.LevelInfo, f.Level())
assert.Equal(t, "info", f.String())
}
func TestLogLevelFlagSetInvalid(t *testing.T) {
f := NewLogLevelFlag()
err := f.Set("invalid")
assert.ErrorContains(t, err, "accepted arguments are ")
}