Merge lp:~rvb/gwacl/export-file-url into lp:gwacl

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: 115
Merged at revision: 116
Proposed branch: lp:~rvb/gwacl/export-file-url
Merge into: lp:gwacl
Diff against target: 158 lines (+17/-17)
3 files modified
storage_base.go (+9/-9)
storage_base_test.go (+7/-7)
storage_test.go (+1/-1)
To merge this branch: bzr merge lp:~rvb/gwacl/export-file-url
Reviewer Review Type Date Requested Status
Gavin Panella Approve
Review via email: mp+170370@code.launchpad.net

Commit message

Export GetFileURL().

Description of the change

Export context.GetFileURL(). I need this to test that the call to gwacl in the provider is using the proper URL. Also (but that's still a hypothesis right now) we might need it to implement storage.URL(filename string).

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
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-06-19 06:56:46 +0000
3+++ storage_base.go 2013-06-19 14:12:29 +0000
4@@ -327,9 +327,9 @@
5 return context.getAccountURL() + url.QueryEscape(container)
6 }
7
8-// getFileURL returns the URL for a given file in the given container.
9+// GetFileURL returns the URL for a given file in the given container.
10 // (The result does not end in a slash.)
11-func (context *StorageContext) getFileURL(container, filename string) string {
12+func (context *StorageContext) GetFileURL(container, filename string) string {
13 return context.getContainerURL(container) + "/" + url.QueryEscape(filename)
14 }
15
16@@ -439,7 +439,7 @@
17
18 _, err := context.performRequest(requestParams{
19 Method: "PUT",
20- URL: context.getFileURL(req.Container, req.Filename),
21+ URL: context.GetFileURL(req.Container, req.Filename),
22 APIVersion: "2012-02-12",
23 ExtraHeaders: extraHeaders,
24 ExpectedStatus: http.StatusCreated,
25@@ -462,7 +462,7 @@
26 // See http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx
27 func (context *StorageContext) PutPage(req *PutPageRequest) error {
28 uri := addURLQueryParams(
29- context.getFileURL(req.Container, req.Filename),
30+ context.GetFileURL(req.Container, req.Filename),
31 "comp", "page")
32
33 extraHeaders := http.Header{}
34@@ -489,7 +489,7 @@
35 // of a block blob.
36 func (context *StorageContext) GetBlockList(container, filename string) (*GetBlockList, error) {
37 uri := addURLQueryParams(
38- context.getFileURL(container, filename),
39+ context.GetFileURL(container, filename),
40 "comp", "blocklist",
41 "blocklisttype", "all")
42 bl := GetBlockList{}
43@@ -511,7 +511,7 @@
44 func (context *StorageContext) PutBlock(container, filename, id string, data io.Reader) error {
45 base64_id := base64.StdEncoding.EncodeToString([]byte(id))
46 uri := addURLQueryParams(
47- context.getFileURL(container, filename),
48+ context.GetFileURL(container, filename),
49 "comp", "block",
50 "blockid", base64_id)
51 _, err := context.performRequest(requestParams{
52@@ -530,7 +530,7 @@
53 // Send a request to piece together blocks into a list that specifies a blob.
54 func (context *StorageContext) PutBlockList(container, filename string, blocklist *BlockList) error {
55 uri := addURLQueryParams(
56- context.getFileURL(container, filename),
57+ context.GetFileURL(container, filename),
58 "comp", "blocklist")
59 data, err := blocklist.Serialize()
60 if err != nil {
61@@ -555,7 +555,7 @@
62 func (context *StorageContext) DeleteBlob(container, filename string) error {
63 _, err := context.performRequest(requestParams{
64 Method: "DELETE",
65- URL: context.getFileURL(container, filename),
66+ URL: context.GetFileURL(container, filename),
67 APIVersion: "2012-02-12",
68 ExpectedStatus: http.StatusAccepted,
69 })
70@@ -570,7 +570,7 @@
71 func (context *StorageContext) GetBlob(container, filename string) (io.ReadCloser, error) {
72 response, err := context.performRequest(requestParams{
73 Method: "GET",
74- URL: context.getFileURL(container, filename),
75+ URL: context.GetFileURL(container, filename),
76 APIVersion: "2012-02-12",
77 ExpectedStatus: http.StatusOK,
78 })
79
80=== modified file 'storage_base_test.go'
81--- storage_base_test.go 2013-06-19 06:41:44 +0000
82+++ storage_base_test.go 2013-06-19 14:12:29 +0000
83@@ -278,7 +278,7 @@
84 file := makeNastyURLUnfriendlyString()
85 context := StorageContext{Account: account}
86 c.Check(
87- context.getFileURL(container, file),
88+ context.GetFileURL(container, file),
89 Equals,
90 "http://"+url.QueryEscape(account)+".blob.core.windows.net/"+url.QueryEscape(container)+"/"+url.QueryEscape(file))
91 }
92@@ -689,7 +689,7 @@
93 c.Assert(err, IsNil)
94
95 // Ensure that container was set right.
96- c.Check(transport.Request.URL.String(), Matches, context.getFileURL("container", "filename")+"?.*")
97+ c.Check(transport.Request.URL.String(), Matches, context.GetFileURL("container", "filename")+"?.*")
98 // Ensure that the Authorization header is set.
99 c.Check(transport.Request.Header.Get("Authorization"), Not(Equals), "")
100 // Check the range is set.
101@@ -754,7 +754,7 @@
102 Container: "container", BlobType: "block", Filename: "blobname"})
103 c.Assert(err, IsNil)
104 // Ensure that container was set right.
105- c.Check(transport.Request.URL.String(), Equals, context.getFileURL("container", "blobname"))
106+ c.Check(transport.Request.URL.String(), Equals, context.GetFileURL("container", "blobname"))
107 // Ensure that the Authorization header is set.
108 c.Check(transport.Request.Header.Get("Authorization"), Not(Equals), "")
109 // The blob type should be a block.
110@@ -838,7 +838,7 @@
111
112 // The blockid should have been base64 encoded and url escaped.
113 base64_id := base64.StdEncoding.EncodeToString([]byte(blockid))
114- c.Check(transport.Request.URL.String(), Matches, context.getFileURL("container", "blobname")+"?.*")
115+ c.Check(transport.Request.URL.String(), Matches, context.GetFileURL("container", "blobname")+"?.*")
116 c.Check(transport.Request.URL.Query(), DeepEquals, url.Values{
117 "comp": {"block"},
118 "blockid": {base64_id},
119@@ -976,7 +976,7 @@
120 context.client = &http.Client{Transport: transport}
121 results, err := context.GetBlockList("container", "myfilename")
122 c.Assert(err, IsNil)
123- c.Check(transport.Request.URL.String(), Matches, context.getFileURL("container", "myfilename")+"?.*")
124+ c.Check(transport.Request.URL.String(), Matches, context.GetFileURL("container", "myfilename")+"?.*")
125 c.Check(transport.Request.URL.Query(), DeepEquals, url.Values{
126 "comp": {"blocklist"},
127 "blocklisttype": {"all"},
128@@ -1024,7 +1024,7 @@
129 c.Assert(err, IsNil)
130
131 c.Check(transport.Request.Method, Equals, "DELETE")
132- c.Check(transport.Request.URL.String(), Equals, context.getFileURL("container", "blobname"))
133+ c.Check(transport.Request.URL.String(), Equals, context.GetFileURL("container", "blobname"))
134 c.Check(transport.Request.Header.Get("Authorization"), Not(Equals), "")
135 c.Check(transport.Request.Body, IsNil)
136 }
137@@ -1076,7 +1076,7 @@
138 defer reader.Close()
139
140 c.Check(transport.Request.Method, Equals, "GET")
141- c.Check(transport.Request.URL.String(), Equals, context.getFileURL("container", "blobname"))
142+ c.Check(transport.Request.URL.String(), Equals, context.GetFileURL("container", "blobname"))
143 c.Check(transport.Request.Header.Get("Authorization"), Not(Equals), "")
144
145 data, err := ioutil.ReadAll(reader)
146
147=== modified file 'storage_test.go'
148--- storage_test.go 2013-06-11 16:31:49 +0000
149+++ storage_test.go 2013-06-19 14:12:29 +0000
150@@ -67,7 +67,7 @@
151
152 func assertBlockSent(
153 c *C, context *StorageContext, data []byte, blockID string, exchange *TestTransport2Exchange) {
154- c.Check(exchange.Request.URL.String(), Matches, context.getFileURL("MyContainer", "MyFile")+"?.*")
155+ c.Check(exchange.Request.URL.String(), Matches, context.GetFileURL("MyContainer", "MyFile")+"?.*")
156 c.Check(exchange.Request.URL.Query(), DeepEquals, url.Values{
157 "comp": {"block"},
158 "blockid": {blockID},

Subscribers

People subscribed via source and target branches

to all changes: