Merge pull request #97 from abperiasamy/time_cleanup

xmltime for bucket response as well
This commit is contained in:
Anand Babu (AB) Periasamy
2015-03-08 17:35:44 -07:00
3 changed files with 8 additions and 12 deletions
+1 -9
View File
@@ -85,10 +85,6 @@ func (c *xmlTime) UnmarshalXMLAttr(attr xml.Attr) error {
return nil
}
func (c *xmlTime) format() string {
return c.Time.Format(xmlTimeFormat)
}
// Total max object list
const (
MaxKeys = 1000
@@ -103,7 +99,7 @@ type Client struct {
// Bucket - carries s3 bucket reply header
type Bucket struct {
Name string
CreationDate string // 2006-02-03T16:45:09.000Z
CreationDate xmlTime
}
func (c *Client) transport() http.RoundTripper {
@@ -191,10 +187,6 @@ func (c *Client) Buckets() ([]*Bucket, error) {
return parseListAllMyBuckets(res.Body)
}
const (
recvFormat = "2006-01-02T15:04:05.000Z"
)
// Stat - returns 0, "", os.ErrNotExist if not on S3
func (c *Client) Stat(key, bucket string) (size int64, date time.Time, reterr error) {
req := newReq(c.keyURL(bucket, key))
+6 -2
View File
@@ -42,6 +42,7 @@ import (
"reflect"
"strings"
"testing"
"time"
)
var tc *Client
@@ -55,9 +56,12 @@ func TestParseBuckets(t *testing.T) {
if g, w := len(buckets), 2; g != w {
t.Errorf("num parsed buckets = %d; want %d", g, w)
}
t1, err := time.Parse(xmlTimeFormat, "2006-06-21T07:04:31.000Z")
t2, err := time.Parse(xmlTimeFormat, "2006-06-21T07:04:32.000Z")
want := []*Bucket{
{Name: "bucketOne", CreationDate: "2006-06-21T07:04:31.000Z"},
{Name: "bucketTwo", CreationDate: "2006-06-21T07:04:32.000Z"},
{Name: "bucketOne", CreationDate: xmlTime{t1}},
{Name: "bucketTwo", CreationDate: xmlTime{t2}},
}
dump := func(v []*Bucket) {
for i, b := range v {
+1 -1
View File
@@ -29,7 +29,7 @@ import (
func printBuckets(v []*s3.Bucket) {
for _, b := range v {
msg := fmt.Sprintf("%v %13s %s", b.CreationDate, "", b.Name)
msg := fmt.Sprintf("%v %13s %s", b.CreationDate.Local(), "", b.Name)
info(msg)
}
}