github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/skip_test.go (about) 1 package functions 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_Skip(t *testing.T) { 10 11 tests := []struct { 12 name string 13 args []interface{} 14 expected interface{} 15 }{ 16 { 17 name: "skip a string", 18 args: []interface{}{ 19 "hello", 20 1, 21 }, 22 expected: "ello", 23 }, 24 { 25 name: "skip beyond the length a string", 26 args: []interface{}{ 27 "hello", 28 6, 29 }, 30 expected: "", 31 }, 32 { 33 name: "skip with a zero count on a string", 34 args: []interface{}{ 35 "hello", 36 0, 37 }, 38 expected: "hello", 39 }, 40 { 41 name: "skip with slice of ints", 42 args: []interface{}{ 43 []int{1, 2, 3, 4, 5}, 44 2, 45 }, 46 expected: []int{3, 4, 5}, 47 }, 48 { 49 name: "skip with slice of strings", 50 args: []interface{}{ 51 []string{"hello", "world"}, 52 1, 53 }, 54 expected: []string{"world"}, 55 }, 56 } 57 58 for _, tt := range tests { 59 t.Run(tt.name, func(t *testing.T) { 60 actual := Skip(tt.args...) 61 assert.Equal(t, tt.expected, actual) 62 }) 63 } 64 65 }