Skip to content

Commit 1097a7d

Browse files
committed
Object Storage v1: Fixing unit test. Changing Timestamp parsing method
1 parent a40ce1e commit 1097a7d

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

openstack/objectstorage/v1/containers/results.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package containers
33
import (
44
"encoding/json"
55
"fmt"
6-
"strconv"
76
"strings"
87
"time"
98

@@ -105,17 +104,16 @@ type GetHeader struct {
105104
StoragePolicy string `json:"X-Storage-Policy"`
106105
TempURLKey string `json:"X-Container-Meta-Temp-URL-Key"`
107106
TempURLKey2 string `json:"X-Container-Meta-Temp-URL-Key-2"`
108-
Timestamp float64 `json:"-"`
107+
Timestamp float64 `json:"X-Timestamp,string"`
109108
}
110109

111110
func (r *GetHeader) UnmarshalJSON(b []byte) error {
112111
type tmp GetHeader
113112
var s struct {
114113
tmp
115-
Write string `json:"X-Container-Write"`
116-
Read string `json:"X-Container-Read"`
117-
Date gophercloud.JSONRFC1123 `json:"Date"`
118-
Timestamp string `json:"X-Timestamp"`
114+
Write string `json:"X-Container-Write"`
115+
Read string `json:"X-Container-Read"`
116+
Date gophercloud.JSONRFC1123 `json:"Date"`
119117
}
120118

121119
err := json.Unmarshal(b, &s)
@@ -130,11 +128,6 @@ func (r *GetHeader) UnmarshalJSON(b []byte) error {
130128

131129
r.Date = time.Time(s.Date)
132130

133-
r.Timestamp, err = strconv.ParseFloat(s.Timestamp, 64)
134-
if err != nil {
135-
return err
136-
}
137-
138131
return err
139132
}
140133

openstack/objectstorage/v1/containers/testing/requests_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func TestGetContainer(t *testing.T) {
157157
TransID: "tx554ed59667a64c61866f1-0057b4ba37",
158158
Write: []string{"test2", "user4"},
159159
StoragePolicy: "test_policy",
160+
Timestamp: 1471298837.95721,
160161
}
161162
actual, err := res.Extract()
162163
th.AssertNoErr(t, err)

0 commit comments

Comments
 (0)