package s3api import ( "testing" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/s3" ) func TestListBucketsHandler(t *testing.T) { expected := ` 2011-04-09T12:34:49Ztest12011-02-09T12:34:49Ztest2` var response ListAllMyBucketsResult var buckets []*s3.Bucket buckets = append(buckets, &s3.Bucket{ Name: aws.String("test1"), CreationDate: aws.Time(time.Date(2011, 4, 9, 12, 34, 49, 0, time.UTC)), }) buckets = append(buckets, &s3.Bucket{ Name: aws.String("test2"), CreationDate: aws.Time(time.Date(2011, 2, 9, 12, 34, 49, 0, time.UTC)), }) response = ListAllMyBucketsResult{ Owner: &s3.Owner{ ID: aws.String(""), DisplayName: aws.String(""), }, Buckets: buckets, } encoded := string(encodeResponse(response)) if encoded != expected { t.Errorf("unexpected output: %s\nexpecting:%s", encoded, expected) } }