github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/credentials/credentials_test.go (about)

     1  package credentials
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestCredentialsString(t *testing.T) {
    11  	for _, test := range []struct {
    12  		c Credentials
    13  		s string
    14  	}{
    15  		{
    16  			NewAnonymousCredentials(),
    17  			"Anonymous{From:\"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestCredentialsString(credentials_test.go:16)\"}", //nolint:lll
    18  		},
    19  		{
    20  			NewAnonymousCredentials(WithSourceInfo("test")),
    21  			"Anonymous{From:\"test\"}",
    22  		},
    23  		{
    24  			NewAccessTokenCredentials("123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"),
    25  			"AccessToken{Token:\"1234****WXYZ(CRC-32c: 81993EA5)\",From:\"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials.TestCredentialsString(credentials_test.go:24)\"}", //nolint:lll
    26  		},
    27  		{
    28  			NewAccessTokenCredentials("123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", WithSourceInfo("test")),
    29  			"AccessToken{Token:\"1234****WXYZ(CRC-32c: 81993EA5)\",From:\"test\"}",
    30  		},
    31  	} {
    32  		t.Run(test.s, func(t *testing.T) {
    33  			if stringer, ok := test.c.(fmt.Stringer); ok {
    34  				require.Equal(t, test.s, stringer.String())
    35  			}
    36  		})
    37  	}
    38  }