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

     1  package functions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  )
     8  
     9  func Test_Empty(t *testing.T) {
    10  	tests := []struct {
    11  		name     string
    12  		args     []interface{}
    13  		expected bool
    14  	}{
    15  		{
    16  			name: "string is empty",
    17  			args: []interface{}{
    18  				"",
    19  			},
    20  			expected: true,
    21  		},
    22  		{
    23  			name: "string is not empty",
    24  			args: []interface{}{
    25  				"hello, world",
    26  			},
    27  			expected: false,
    28  		},
    29  		{
    30  			name: "array is empty",
    31  			args: []interface{}{
    32  				[]string{},
    33  			},
    34  			expected: true,
    35  		},
    36  		{
    37  			name: "array is not empty",
    38  			args: []interface{}{
    39  				[]string{"Hello", "World"},
    40  			},
    41  			expected: false,
    42  		},
    43  		{
    44  			name: "map is empty",
    45  			args: []interface{}{
    46  				map[string]interface{}{},
    47  			},
    48  			expected: true,
    49  		},
    50  		{
    51  			name: "map is not empty",
    52  			args: []interface{}{
    53  				map[string]interface{}{
    54  					"hello": "world",
    55  				},
    56  				"world",
    57  			},
    58  			expected: false,
    59  		},
    60  	}
    61  
    62  	for _, tt := range tests {
    63  		t.Run(tt.name, func(t *testing.T) {
    64  			doesContain := Empty(tt.args...)
    65  			require.Equal(t, tt.expected, doesContain)
    66  		})
    67  	}
    68  }