Should always return an array
I thought search would return an empty array. Apparently it it is not, and not a bad thing to make sure that it always does. http://paste.openstack.org/show/40125/ Change-Id: Ia39a092ffae69f94619ac9c640c1ffcc4d70510f
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
This file is used to list changes made in each version of cookbook-openstack-common.
|
||||
|
||||
## 0.3.4:
|
||||
* Allow `#search_for` to always returns an array.
|
||||
|
||||
## 0.3.3:
|
||||
* Incorrectly mocked search results, as a result `#search_for` was performing unnecessary
|
||||
actions to an array.
|
||||
|
||||
@@ -25,7 +25,8 @@ module ::Openstack
|
||||
def search_for role, &block
|
||||
query = "chef_environment:#{node.chef_environment} AND roles:#{role}"
|
||||
|
||||
search(:node, query, &block)
|
||||
resp = search(:node, query, &block)
|
||||
resp ? resp : []
|
||||
end
|
||||
|
||||
# Returns the value for ["openstack"]["memcached_servers"] when
|
||||
|
||||
@@ -33,6 +33,16 @@ describe ::Openstack do
|
||||
|
||||
expect(resp).to eq []
|
||||
end
|
||||
|
||||
it "always returns empty results" do
|
||||
@subject.stub(:node).and_return @chef_run.node
|
||||
@subject.stub(:search).
|
||||
with(:node, "chef_environment:_default AND roles:empty-role").
|
||||
and_return nil
|
||||
resp = @subject.search_for("empty-role")
|
||||
|
||||
expect(resp).to eq []
|
||||
end
|
||||
end
|
||||
|
||||
describe "#memcached_servers" do
|
||||
|
||||
Reference in New Issue
Block a user