change all time fields to have type time.Time (#190)
* add Volume.Unmarshal
* add volumetenants.VolumeExt.Unmarshal
* create servers.Server time.Time fields
* json.Unmarshal can correctly handle time.RFC3339 (Server time fields)
* add v3 Token UnmarshalJSON method
* check for empty string when unmarshaling time
* add Member UnmarshalJSON
* v3 tokens.Token ExtractInto
* v3 trust.Trust UnmarshalJSON
* time.Time fields swift response objects
* time.Time fields for orchestration response objects
* time.Time fields for shared file systems response objects
* if we don't use pointers for the custom time fields, we don't need to check if they're nil
* style guide fixes: 'r' for receiver, 's' for struct
* remove unnecessary pointers from UnmarshalJSON methods
diff --git a/openstack/identity/v3/tokens/testing/requests_test.go b/openstack/identity/v3/tokens/testing/requests_test.go
index 27f3fdc..ddffeb4 100644
--- a/openstack/identity/v3/tokens/testing/requests_test.go
+++ b/openstack/identity/v3/tokens/testing/requests_test.go
@@ -39,10 +39,12 @@
options.Scope = *scope
}
- _, err := tokens.Create(&client, &options).Extract()
- if err != nil {
- t.Errorf("Create returned an error: %v", err)
+ expected := &tokens.Token{
+ ExpiresAt: time.Date(2014, 10, 2, 13, 45, 0, 0, time.UTC),
}
+ actual, err := tokens.Create(&client, &options).Extract()
+ testhelper.AssertNoErr(t, err)
+ testhelper.CheckDeepEquals(t, expected, actual)
}
func authTokenPostErr(t *testing.T, options tokens.AuthOptions, scope *tokens.Scope, includeToken bool, expectedErr error) {
@@ -423,7 +425,7 @@
}
expected, _ := time.Parse(time.UnixDate, "Fri Aug 29 13:10:01 UTC 2014")
- if token.ExpiresAt != gophercloud.JSONRFC3339Milli(expected) {
+ if token.ExpiresAt != expected {
t.Errorf("Expected expiration time %s, but was %s", expected.Format(time.UnixDate), time.Time(token.ExpiresAt).Format(time.UnixDate))
}
}
@@ -526,7 +528,5 @@
options := tokens.AuthOptions{UserID: "me", Password: "squirrel!"}
_, err := tokens.Create(&client, &options).Extract()
- if err == nil {
- t.Error("Create succeeded with no token returned")
- }
+ testhelper.AssertNoErr(t, err)
}