// nolint lines are duplicate of `pkg/edge/api/utils/log_classification_helper_test.go` package utils import ( "testing" "github.com/stretchr/testify/assert" "edge-infra.dev/pkg/edge/api/graph/model" ) func TestToInjectableConfigmap(t *testing.T) { testcases := []struct { title string value string expected model.InjectableConfigmaps assertionFunc func(t *testing.T, err error, expected, actual model.InjectableConfigmaps) }{ { title: "Test Case 1 - Edge Info", value: "edge-info", expected: model.InjectableConfigmapsEdgeInfo, assertionFunc: func(t *testing.T, err error, expected, actual model.InjectableConfigmaps) { assert.NoError(t, err) assert.Equal(t, expected, actual) }, }, { title: "Test Case 2 - BSL Info", value: "bsl-info", expected: model.InjectableConfigmapsBSLInfo, assertionFunc: func(t *testing.T, err error, expected, actual model.InjectableConfigmaps) { assert.NoError(t, err) assert.Equal(t, expected, actual) }, }, { title: "Test Case 3 - Invalid Edge Info Injectable Configmap Value", value: "invalid-edge-info", expected: model.InjectableConfigmapsEdgeInfo, assertionFunc: func(t *testing.T, err error, expected, actual model.InjectableConfigmaps) { assert.Error(t, err) assert.NotEqual(t, expected, actual) }, }, { title: "Test Case 4 - Invalid BSl Info Injectable Configmap Value", value: "invalid-edge-info", expected: model.InjectableConfigmapsBSLInfo, assertionFunc: func(t *testing.T, err error, expected, actual model.InjectableConfigmaps) { assert.Error(t, err) assert.NotEqual(t, expected, actual) }, }, } for _, testcase := range testcases { t.Run(testcase.title, func(t *testing.T) { actual, err := ToInjectableConfigmap(testcase.value) testcase.assertionFunc(t, err, testcase.expected, actual) }) } }