Merge lp:~julian-edwards/gwacl/fix-get-container-props into lp:gwacl

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: 207
Merged at revision: 207
Proposed branch: lp:~julian-edwards/gwacl/fix-get-container-props
Merge into: lp:gwacl
Diff against target: 52 lines (+26/-5)
2 files modified
storage_base.go (+5/-5)
storage_base_test.go (+21/-0)
To merge this branch: bzr merge lp:~julian-edwards/gwacl/fix-get-container-props
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+177808@code.launchpad.net

Commit message

Allow for optional headers in the GetContainerProperties response.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storage_base.go'
2--- storage_base.go 2013-07-31 06:31:36 +0000
3+++ storage_base.go 2013-07-31 11:35:33 +0000
4@@ -468,11 +468,11 @@
5 }
6
7 props := &Properties{
8- LastModified: headers[http.CanonicalHeaderKey("Last-Modified")][0],
9- ETag: headers[http.CanonicalHeaderKey("ETag")][0],
10- LeaseStatus: headers[http.CanonicalHeaderKey("X-Ms-Lease-Status")][0],
11- LeaseState: headers[http.CanonicalHeaderKey("X-Ms-Lease-State")][0],
12- LeaseDuration: headers[http.CanonicalHeaderKey("X-Ms-Lease-Duration")][0],
13+ LastModified: headers.Get(http.CanonicalHeaderKey("Last-Modified")),
14+ ETag: headers.Get(http.CanonicalHeaderKey("ETag")),
15+ LeaseStatus: headers.Get(http.CanonicalHeaderKey("X-Ms-Lease-Status")),
16+ LeaseState: headers.Get(http.CanonicalHeaderKey("X-Ms-Lease-State")),
17+ LeaseDuration: headers.Get(http.CanonicalHeaderKey("X-Ms-Lease-Duration")),
18 }
19
20 return props, nil
21
22=== modified file 'storage_base_test.go'
23--- storage_base_test.go 2013-07-31 06:21:01 +0000
24+++ storage_base_test.go 2013-07-31 11:35:33 +0000
25@@ -781,6 +781,27 @@
26 c.Check(props.LeaseDuration, Equals, "duration")
27 }
28
29+func (suite *TestGetContainerProperties) TestWithoutAllHeaders(c *C) {
30+ response := &http.Response{
31+ Status: fmt.Sprintf("%d", http.StatusOK),
32+ StatusCode: http.StatusOK,
33+ Body: makeResponseBody(""),
34+ }
35+
36+ transport := &TestTransport{Response: response}
37+ context := makeStorageContext(transport)
38+ containerName := MakeRandomString(10)
39+ props, err := context.GetContainerProperties(containerName)
40+ c.Assert(err, IsNil)
41+
42+ c.Check(props.LastModified, Equals, "")
43+ c.Check(props.ETag, Equals, "")
44+ c.Check(props.LeaseStatus, Equals, "")
45+ c.Check(props.LeaseState, Equals, "")
46+ c.Check(props.LeaseDuration, Equals, "")
47+}
48+
49+
50 // Client-side errors from the HTTP client are propagated back to the caller.
51 func (suite *TestGetContainerProperties) TestError(c *C) {
52 error := fmt.Errorf("canned-error")

Subscribers

People subscribed via source and target branches

to all changes: