github.com/saucelabs/saucectl@v0.175.1/internal/cmd/configure/cmd_test.go (about)

     1  package configure
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func Test_mask(t *testing.T) {
    10  	testcases := []struct {
    11  		name   string
    12  		input  string
    13  		expect string
    14  	}{
    15  		{
    16  			name:   "it should mask access key",
    17  			input:  "1234567-8912-3456-7891-234567891234",
    18  			expect: "*******-****-****-****-********1234",
    19  		},
    20  		{
    21  			name:   "it should return empty string when input is empty",
    22  			input:  "",
    23  			expect: "",
    24  		},
    25  	}
    26  
    27  	for _, tc := range testcases {
    28  		t.Run(tc.name, func(t *testing.T) {
    29  			result := mask(tc.input)
    30  			assert.Equal(t, tc.expect, result)
    31  		})
    32  	}
    33  }