github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/if_test.go (about) 1 package functions 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_If(t *testing.T) { 10 11 tests := []struct { 12 name string 13 args []interface{} 14 expected interface{} 15 }{ 16 { 17 name: "If with true", 18 args: []interface{}{true, "true", "false"}, 19 expected: "true", 20 }, 21 { 22 name: "If with false", 23 args: []interface{}{false, "true", "false"}, 24 expected: "false", 25 }, 26 { 27 name: "If with true and slice returned", 28 args: []interface{}{ 29 true, 30 []interface{}{"Hello", "World"}, 31 []interface{}{"Goodbye", "World"}, 32 }, 33 expected: []interface{}{"Hello", "World"}, 34 }, 35 } 36 37 for _, tt := range tests { 38 t.Run(tt.name, func(t *testing.T) { 39 got := If(tt.args...) 40 assert.Equal(t, tt.expected, got) 41 }) 42 } 43 44 }