github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/create_array_test.go (about) 1 package functions 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_CreateArray(t *testing.T) { 10 11 tests := []struct { 12 name string 13 args []interface{} 14 expected interface{} 15 }{ 16 { 17 name: "create array with strings", 18 args: []interface{}{ 19 "Hello", 20 "World", 21 }, 22 expected: []interface{}{"Hello", "World"}, 23 }, 24 { 25 name: "create array with ints", 26 27 args: []interface{}{ 28 1, 2, 3, 29 }, 30 expected: []interface{}{1, 2, 3}, 31 }, 32 { 33 name: "create array with arrays", 34 args: []interface{}{ 35 []interface{}{1, 2, 3}, 36 []interface{}{4, 5, 6}, 37 }, 38 expected: []interface{}{[]interface{}{1, 2, 3}, []interface{}{4, 5, 6}}, 39 }, 40 { 41 name: "create arrau with maps", 42 args: []interface{}{ 43 map[string]interface{}{ 44 "one": "a", 45 }, 46 map[string]interface{}{ 47 "two": "b", 48 }, 49 }, 50 expected: []interface{}{ 51 map[string]interface{}{ 52 "one": "a", 53 }, 54 map[string]interface{}{ 55 "two": "b", 56 }, 57 }, 58 }, 59 } 60 61 for _, tt := range tests { 62 t.Run(tt.name, func(t *testing.T) { 63 actual := CreateArray(tt.args...) 64 assert.Equal(t, tt.expected, actual) 65 }) 66 } 67 68 }