...

Source file src/edge-infra.dev/pkg/edge/api/utils/helm_helper_test.go

Documentation: edge-infra.dev/pkg/edge/api/utils

     1  // nolint lines are duplicate of `pkg/edge/api/utils/log_classification_helper_test.go`
     2  package utils
     3  
     4  import (
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  
     9  	"edge-infra.dev/pkg/edge/api/graph/model"
    10  )
    11  
    12  func TestToInjectableConfigmap(t *testing.T) {
    13  	testcases := []struct {
    14  		title         string
    15  		value         string
    16  		expected      model.InjectableConfigmaps
    17  		assertionFunc func(t *testing.T, err error, expected, actual model.InjectableConfigmaps)
    18  	}{
    19  		{
    20  			title:    "Test Case 1 - Edge Info",
    21  			value:    "edge-info",
    22  			expected: model.InjectableConfigmapsEdgeInfo,
    23  			assertionFunc: func(t *testing.T, err error, expected, actual model.InjectableConfigmaps) {
    24  				assert.NoError(t, err)
    25  				assert.Equal(t, expected, actual)
    26  			},
    27  		},
    28  		{
    29  			title:    "Test Case 2 - BSL Info",
    30  			value:    "bsl-info",
    31  			expected: model.InjectableConfigmapsBSLInfo,
    32  			assertionFunc: func(t *testing.T, err error, expected, actual model.InjectableConfigmaps) {
    33  				assert.NoError(t, err)
    34  				assert.Equal(t, expected, actual)
    35  			},
    36  		},
    37  		{
    38  			title:    "Test Case 3 - Invalid Edge Info Injectable Configmap Value",
    39  			value:    "invalid-edge-info",
    40  			expected: model.InjectableConfigmapsEdgeInfo,
    41  			assertionFunc: func(t *testing.T, err error, expected, actual model.InjectableConfigmaps) {
    42  				assert.Error(t, err)
    43  				assert.NotEqual(t, expected, actual)
    44  			},
    45  		},
    46  		{
    47  			title:    "Test Case 4 - Invalid BSl Info Injectable Configmap Value",
    48  			value:    "invalid-edge-info",
    49  			expected: model.InjectableConfigmapsBSLInfo,
    50  			assertionFunc: func(t *testing.T, err error, expected, actual model.InjectableConfigmaps) {
    51  				assert.Error(t, err)
    52  				assert.NotEqual(t, expected, actual)
    53  			},
    54  		},
    55  	}
    56  
    57  	for _, testcase := range testcases {
    58  		t.Run(testcase.title, func(t *testing.T) {
    59  			actual, err := ToInjectableConfigmap(testcase.value)
    60  			testcase.assertionFunc(t, err, testcase.expected, actual)
    61  		})
    62  	}
    63  }
    64  

View as plain text