package xmlutil_test import ( "net/http" "net/http/httptest" "testing" "github.com/stretchr/testify/assert" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/awstesting/unit" "github.com/aws/aws-sdk-go/service/s3" ) func TestUnmarshal(t *testing.T) { xmlVal := []byte(` foo-id user foo-id user FULL_CONTROL `) var server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write(xmlVal) })) sess := unit.Session sess.Config.Endpoint = &server.URL sess.Config.S3ForcePathStyle = aws.Bool(true) svc := s3.New(sess) out, err := svc.GetBucketAcl(&s3.GetBucketAclInput{ Bucket: aws.String("foo"), }) assert.NoError(t, err) expected := &s3.GetBucketAclOutput{ Grants: []*s3.Grant{ { Grantee: &s3.Grantee{ DisplayName: aws.String("user"), ID: aws.String("foo-id"), Type: aws.String("type"), }, Permission: aws.String("FULL_CONTROL"), }, }, Owner: &s3.Owner{ DisplayName: aws.String("user"), ID: aws.String("foo-id"), }, } assert.Equal(t, expected, out) }