package s3api import ( "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" "testing" "time" ) func TestListBucketsHandler(t *testing.T) { expected := ` test12011-04-09T12:34:49Ztest22011-02-09T12:34:49Z` var response ListAllMyBucketsResult var bucketsList ListAllMyBucketsList bucketsList.Bucket = append(bucketsList.Bucket, ListAllMyBucketsEntry{ Name: "test1", CreationDate: time.Date(2011, 4, 9, 12, 34, 49, 0, time.UTC), }) bucketsList.Bucket = append(bucketsList.Bucket, ListAllMyBucketsEntry{ Name: "test2", CreationDate: time.Date(2011, 2, 9, 12, 34, 49, 0, time.UTC), }) response = ListAllMyBucketsResult{ Owner: CanonicalUser{ ID: "", DisplayName: "", }, Buckets: bucketsList, } encoded := string(s3err.EncodeXMLResponse(response)) if encoded != expected { t.Errorf("unexpected output:%s\nexpecting:%s", encoded, expected) } }