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

     1  package functions
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func Test_Replace(t *testing.T) {
    10  	tests := []struct {
    11  		name     string
    12  		args     []interface{}
    13  		expected string
    14  	}{
    15  		{
    16  			name: "replace a string",
    17  			args: []interface{}{
    18  				"hello",
    19  				"l",
    20  				"p",
    21  			},
    22  			expected: "heppo",
    23  		},
    24  		{
    25  			name: "replace a string with invalid replacement",
    26  			args: []interface{}{
    27  				"hello",
    28  				"q",
    29  				"p",
    30  			},
    31  			expected: "hello",
    32  		},
    33  	}
    34  
    35  	for _, tt := range tests {
    36  		t.Run(tt.name, func(t *testing.T) {
    37  			actual := Replace(tt.args...)
    38  			assert.Equal(t, tt.expected, actual)
    39  		})
    40  	}
    41  }