You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
1.1 KiB

package s3api
import (
"github.com/seaweedfs/seaweedfs/weed/s3api/s3err"
"testing"
"time"
)
func TestListBucketsHandler(t *testing.T) {
expected := `<?xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult><Owner><ID></ID></Owner><Buckets><Bucket><Name>test1</Name><CreationDate>2011-04-09T12:34:49Z</CreationDate></Bucket><Bucket><Name>test2</Name><CreationDate>2011-02-09T12:34:49Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>`
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)
}
}