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