github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/array_test.go (about)

     1  package functions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func Test_Array(t *testing.T) {
    10  	test := []struct {
    11  		name     string
    12  		input    []interface{}
    13  		expected interface{}
    14  	}{
    15  		{
    16  			name:     "array from an int",
    17  			input:    []interface{}{1},
    18  			expected: []int{1},
    19  		},
    20  		{
    21  			name:     "array from a string",
    22  			input:    []interface{}{"hello"},
    23  			expected: []string{"hello"},
    24  		},
    25  		{
    26  			name:     "array from a map",
    27  			input:    []interface{}{map[string]interface{}{"hello": "world"}},
    28  			expected: []interface{}{"hello", "world"},
    29  		},
    30  		{
    31  			name: "array from an slice",
    32  			input: []interface{}{
    33  				[]string{"hello", "world"},
    34  			},
    35  			expected: []string{"hello", "world"},
    36  		},
    37  	}
    38  	for _, tt := range test {
    39  		t.Run(tt.name, func(t *testing.T) {
    40  			actual := Array(tt.input...)
    41  			assert.Equal(t, tt.expected, actual)
    42  		})
    43  	}
    44  }