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

     1  package functions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func Test_FormatCall(t *testing.T) {
    10  
    11  	tests := []struct {
    12  		name     string
    13  		args     []interface{}
    14  		expected string
    15  	}{
    16  		{
    17  			name: "simple format call",
    18  			args: []interface{}{
    19  				"{0}/{1}",
    20  				"myPostgreSQLServer",
    21  				"log_checkpoints",
    22  			},
    23  			expected: "myPostgreSQLServer/log_checkpoints",
    24  		},
    25  		{
    26  			name: "complex format call",
    27  			args: []interface{}{
    28  				"{0} + {1} = {2}",
    29  				1, 2, 3,
    30  			},
    31  			expected: "1 + 2 = 3",
    32  		},
    33  	}
    34  
    35  	for _, tt := range tests {
    36  		t.Run(tt.name, func(t *testing.T) {
    37  			actual := Format(tt.args...)
    38  			assert.Equal(t, tt.expected, actual)
    39  		})
    40  	}
    41  
    42  }