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

     1  package functions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func Test_ToLower(t *testing.T) {
    10  
    11  	tests := []struct {
    12  		name     string
    13  		args     []interface{}
    14  		expected string
    15  	}{
    16  		{
    17  			name: "lowercase a string",
    18  			args: []interface{}{
    19  				"HELLO",
    20  			},
    21  			expected: "hello",
    22  		},
    23  		{
    24  			name: "lowercase a string with a non-string input",
    25  			args: []interface{}{
    26  				10,
    27  			},
    28  			expected: "",
    29  		},
    30  	}
    31  
    32  	for _, tt := range tests {
    33  		t.Run(tt.name, func(t *testing.T) {
    34  			actual := ToLower(tt.args...)
    35  			assert.Equal(t, tt.expected, actual)
    36  		})
    37  	}
    38  
    39  }
    40  
    41  func Test_ToUpper(t *testing.T) {
    42  
    43  	tests := []struct {
    44  		name     string
    45  		args     []interface{}
    46  		expected string
    47  	}{
    48  		{
    49  			name: "uppercase a string",
    50  			args: []interface{}{
    51  				"hello",
    52  			},
    53  			expected: "HELLO",
    54  		},
    55  		{
    56  			name: "uppercase a string with a non-string input",
    57  			args: []interface{}{
    58  				10,
    59  			},
    60  			expected: "",
    61  		},
    62  	}
    63  
    64  	for _, tt := range tests {
    65  		t.Run(tt.name, func(t *testing.T) {
    66  			actual := ToUpper(tt.args...)
    67  			assert.Equal(t, tt.expected, actual)
    68  		})
    69  	}
    70  
    71  }