summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Magnus Rakvåg <tm@intility.no>2017-08-07 16:07:05 +0200
committerTor Magnus Rakvåg <tm@intility.no>2017-08-07 16:08:03 +0200
commita01443cd55da0343eec924fa61f45e818335cd21 (patch)
treec6f94f12964d54fc3ffc3f2fb513e69bba5c09ea
parent0c8cd3a31adfe376bff41af716ff9c2a49f2838f (diff)
downloadchef-a01443cd55da0343eec924fa61f45e818335cd21.tar.gz
throw readable errors if multiple dsc resources are found
Signed-off-by: Tor Magnus Rakvåg <tm@intility.no>
-rw-r--r--lib/chef/exceptions.rb2
-rw-r--r--spec/unit/provider/dsc_resource_spec.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index a09a3a062c..68bcdf9eb5 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -515,7 +515,7 @@ This error is most often caused by network issues (proxies, etc) outside of chef
"Resource #{r['Name']} is a binary resource"
end
end
- super "Found multiple matching resources. #{matches_info.join("\n")}"
+ super "Found multiple matching resources of #{matches_info[0]["Module"]["Name"]}:\n#{(matches_info.map { |f| f["Module"]["Version"] }).uniq.join("\n")}"
end
end
diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb
index 96356e5d73..747e37f308 100644
--- a/spec/unit/provider/dsc_resource_spec.rb
+++ b/spec/unit/provider/dsc_resource_spec.rb
@@ -155,8 +155,8 @@ describe Chef::Provider::DscResource do
context "multiple resource are found" do
let (:resource_records) do
[
- { "Module" => { "Name" => "ModuleName1" } },
- { "Module" => { "Name" => "ModuleName2" } },
+ { "Module" => { "Name" => "ModuleName1", "Version" => "1.0.0.0" } },
+ { "Module" => { "Name" => "ModuleName1", "Version" => "2.0.0.0" } },
] end
it "raises MultipleDscResourcesFound" do