github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/first_test.go (about) 1 package functions 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func Test_First(t *testing.T) { 10 test := []struct { 11 name string 12 args []interface{} 13 expected interface{} 14 }{ 15 { 16 name: "first in empty string", 17 args: []interface{}{ 18 "", 19 }, 20 expected: "", 21 }, 22 { 23 name: "first in string", 24 args: []interface{}{ 25 "Hello", 26 }, 27 expected: "H", 28 }, 29 { 30 name: "first in empty slice", 31 args: []interface{}{ 32 []string{}, 33 }, 34 expected: "", 35 }, 36 { 37 name: "first in slice", 38 args: []interface{}{ 39 []string{"Hello", "World"}, 40 }, 41 expected: "Hello", 42 }, 43 } 44 45 for _, tt := range test { 46 t.Run(tt.name, func(t *testing.T) { 47 actual := First(tt.args...) 48 require.Equal(t, tt.expected, actual) 49 }) 50 } 51 }