aboutsummaryrefslogtreecommitdiff
path: root/field_test.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2018-02-17 18:07:39 +0100
committerStefan Majewsky <majewsky@gmx.net>2018-02-17 18:12:16 +0100
commit725ffa66897cf2d8943e4fcedc354abea4899324 (patch)
tree1ae98ab1511f2965bf6d488e46af28269a7af9be /field_test.go
parentc445dcf3b6062a99a135036d60ac5b055cee9d2b (diff)
downloadgo-schwift-725ffa66897cf2d8943e4fcedc354abea4899324.tar.gz
add test for FieldHTTPTimeReadonly
Diffstat (limited to 'field_test.go')
-rw-r--r--field_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/field_test.go b/field_test.go
index c931108..c86f07d 100644
--- a/field_test.go
+++ b/field_test.go
@@ -19,6 +19,7 @@
package schwift
import (
+ "net/http"
"strconv"
"testing"
)
@@ -82,6 +83,36 @@ func TestFieldTimestamp(t *testing.T) {
expectError(t, hdr.Validate(), `Bad header X-Timestamp: strconv.ParseFloat: parsing "wtf": invalid syntax`)
}
+func TestFieldHTTPTimestamp(t *testing.T) {
+ testWithContainer(t, func(c *Container) {
+ obj := c.Object("test")
+ err := obj.Upload(nil, nil, nil)
+ if !expectSuccess(t, err) {
+ return
+ }
+
+ hdr, err := obj.Headers()
+ if !expectSuccess(t, err) {
+ return
+ }
+ expectBool(t, hdr.UpdatedAt().Exists(), true)
+
+ actual := hdr.UpdatedAt().Get()
+ expected, _ := http.ParseTime(hdr.Get("Last-Modified"))
+ expectInt64(t, actual.Unix(), expected.Unix())
+ })
+
+ hdr := make(ObjectHeaders)
+ expectBool(t, hdr.UpdatedAt().Exists(), false)
+ expectBool(t, hdr.UpdatedAt().Get().IsZero(), true)
+ expectError(t, hdr.Validate(), "")
+
+ hdr["Last-Modified"] = "wtf"
+ expectBool(t, hdr.UpdatedAt().Exists(), true)
+ expectBool(t, hdr.UpdatedAt().Get().IsZero(), true)
+ expectError(t, hdr.Validate(), `Bad header Last-Modified: parsing time "wtf" as "Mon Jan _2 15:04:05 2006": cannot parse "wtf" as "Mon"`)
+}
+
////////////////////////////////////////////////////////////////////////////////
func TestFieldUint64(t *testing.T) {