sort RA parameters for deterministic tests

This commit is contained in:
Adam Spiers 2014-01-23 15:05:40 +00:00
parent 7f5a799e02
commit 73a377cc75
2 changed files with 7 additions and 7 deletions

View File

@ -37,7 +37,7 @@ module Chef::Libraries
def resource_params_string(params) def resource_params_string(params)
return "" if ! params or params.empty? return "" if ! params or params.empty?
s = " params" s = " params"
params.each do |key, value| params.sort.each do |key, value|
s << %' #{key}="#{value}"' s << %' #{key}="#{value}"'
end end
s s
@ -46,7 +46,7 @@ module Chef::Libraries
def resource_meta_string(meta) def resource_meta_string(meta)
return "" if ! meta or meta.empty? return "" if ! meta or meta.empty?
s = " meta" s = " meta"
meta.each do |key, value| meta.sort.each do |key, value|
s << %' #{key}="#{value}"' s << %' #{key}="#{value}"'
end end
s s
@ -55,9 +55,9 @@ module Chef::Libraries
def resource_op_string(ops) def resource_op_string(ops)
return "" if ! ops or ops.empty? return "" if ! ops or ops.empty?
s = " op" s = " op"
ops.each do |op, attrs| ops.sort.each do |op, attrs|
s << " #{op}" s << " #{op}"
attrs.each do |key, value| attrs.sort.each do |key, value|
s << %' #{key}="#{value}"' s << %' #{key}="#{value}"'
end end
end end

View File

@ -113,7 +113,7 @@ describe Chef::Libraries::Pacemaker::CIBObjects do
"foo" => "bar", "foo" => "bar",
"baz" => "qux", "baz" => "qux",
} }
expect(resource_params_string(params)).to eq(%' params foo="bar" baz="qux"') expect(resource_params_string(params)).to eq(%' params baz="qux" foo="bar"')
end end
end end
@ -131,7 +131,7 @@ describe Chef::Libraries::Pacemaker::CIBObjects do
"foo" => "bar", "foo" => "bar",
"baz" => "qux", "baz" => "qux",
} }
expect(resource_meta_string(meta)).to eq(%' meta foo="bar" baz="qux"') expect(resource_meta_string(meta)).to eq(%' meta baz="qux" foo="bar"')
end end
end end
@ -151,7 +151,7 @@ describe Chef::Libraries::Pacemaker::CIBObjects do
"baz" => "qux", "baz" => "qux",
} }
} }
expect(resource_op_string(op)).to eq(%' op monitor foo="bar" baz="qux"') expect(resource_op_string(op)).to eq(%' op monitor baz="qux" foo="bar"')
end end
end end