-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking for public_url and put_object #341
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,27 @@ def url | |
"#{@scheme}://#{@host}:#{@port}#{@path}" | ||
end | ||
end | ||
|
||
class Mock | ||
# Get public_url for an object | ||
# | ||
# ==== Parameters | ||
# * container<~String> - Name of container to look in | ||
# * object<~String> - Name of object to look for | ||
# | ||
def public_url(container = nil, object = nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you try enabling some of the tests we currently skip in |
||
return nil if container.nil? | ||
u = "#{url}/#{Fog::OpenStack.escape(container)}" | ||
u << "/#{Fog::OpenStack.escape(object)}" unless object.nil? | ||
u | ||
end | ||
|
||
private | ||
|
||
def url | ||
"#{@scheme}://#{@host}:#{@port}#{@path}" | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,15 @@ def put_object(container, object, data, options = {}, &block) | |
request(params) | ||
end | ||
end | ||
|
||
class Mock | ||
def put_object(container, object, data, options = {}, &block) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused method argument - container. If it's necessary, use _ or _container as an argument name to indicate that it won't be used. You can also write as put_object() if you want the method to accept any arguments but don't care about them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Swift returns the |
||
response = Excon::Response.new | ||
response.status = 201 | ||
response.body = "" | ||
response | ||
end | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks duplicated from
OpenStack::Core.authenticate
, which I guess is only included in theReal
classes (e.g. instorage/openstack.rb
). I looked around and couldn't find a better way to fit this. We could make a mixin that just parses the management URL, but it seems a bit silly. I think this is ok, but if you have an idea on how to avoid duplicating this code, I'd be all ears.