...

Source file src/github.com/aws/aws-sdk-go-v2/internal/awsutil/string_value_test.go

Documentation: github.com/aws/aws-sdk-go-v2/internal/awsutil

     1  package awsutil_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/aws/aws-sdk-go-v2/internal/awsutil"
     7  	"github.com/aws/smithy-go/ptr"
     8  )
     9  
    10  type testStruct struct {
    11  	Field1 string
    12  	Field2 *string
    13  	Field3 []byte `sensitive:"true"`
    14  	Value  []string
    15  }
    16  
    17  func TestStringValue(t *testing.T) {
    18  	cases := map[string]struct {
    19  		Value  interface{}
    20  		Expect string
    21  	}{
    22  		"general": {
    23  			Value: testStruct{
    24  				Field1: "abc123",
    25  				Field2: ptr.String("abc123"),
    26  				Field3: []byte("don't show me"),
    27  				Value: []string{
    28  					"first",
    29  					"second",
    30  				},
    31  			},
    32  			Expect: `{
    33    Field1: "abc123",
    34    Field2: "abc123",
    35    Field3: <sensitive>,
    36    Value: ["first","second"],
    37  
    38  }`,
    39  		},
    40  	}
    41  
    42  	for d, c := range cases {
    43  		t.Run(d, func(t *testing.T) {
    44  			actual := awsutil.StringValue(c.Value)
    45  			if e, a := c.Expect, actual; e != a {
    46  				t.Errorf("expect:\n%v\nactual:\n%v\n", e, a)
    47  			}
    48  		})
    49  	}
    50  }
    51  

View as plain text