Files
velero/pkg/cmd/util/flag/enum_test.go
Wenkai Yin(尹文开) e92047c43e Add unit test cases for pkg/cmd/util/flag package
Add unit test cases for pkg/cmd/util/flag package

Fixes #6253

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
2023-06-01 10:29:11 +08:00

32 lines
665 B
Go

package flag
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestStringOfEnum(t *testing.T) {
enum := NewEnum("a", "a", "b", "c")
assert.Equal(t, "a", enum.String())
}
func TestSetOfEnum(t *testing.T) {
enum := NewEnum("a", "a", "b", "c")
assert.NotNil(t, enum.Set("d"))
require.Nil(t, enum.Set("b"))
assert.Equal(t, "b", enum.String())
}
func TestTypeOfEnum(t *testing.T) {
enum := NewEnum("a", "a", "b", "c")
assert.Equal(t, "", enum.Type())
}
func TestAllowedValuesOfEnum(t *testing.T) {
enum := NewEnum("a", "a", "b", "c")
assert.Equal(t, []string{"a", "b", "c"}, enum.AllowedValues())
}