bottle: add tests for merge_bottle_spec
This commit is contained in:
parent
6f606b4e58
commit
4cbd4f296b
@ -549,24 +549,26 @@ module Homebrew
|
|||||||
new_values = {
|
new_values = {
|
||||||
root_url: new_bottle_hash["root_url"],
|
root_url: new_bottle_hash["root_url"],
|
||||||
prefix: new_bottle_hash["prefix"],
|
prefix: new_bottle_hash["prefix"],
|
||||||
cellar: new_bottle_hash["cellar"].to_sym,
|
cellar: new_bottle_hash["cellar"],
|
||||||
rebuild: new_bottle_hash["rebuild"],
|
rebuild: new_bottle_hash["rebuild"],
|
||||||
}
|
}
|
||||||
|
|
||||||
old_keys.each do |key|
|
old_keys.each do |key|
|
||||||
next if key == :sha256
|
next if key == :sha256
|
||||||
|
|
||||||
old_value = old_bottle_spec.send(key)
|
old_value = old_bottle_spec.send(key).to_s
|
||||||
new_value = new_values[key]
|
new_value = new_values[key].to_s
|
||||||
next if key == :cellar && old_value == :any && new_value == :any_skip_relocation
|
next if key == :cellar && old_value == "any" && new_value == "any_skip_relocation"
|
||||||
next if old_value.present? && new_value == old_value
|
next if old_value.present? && new_value == old_value
|
||||||
|
|
||||||
mismatches << "#{key}: old: #{old_value.inspect}, new: #{new_value.inspect}"
|
mismatches << "#{key}: old: #{old_value.inspect}, new: #{new_value.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return [mismatches, checksums] unless old_keys.include? :sha256
|
||||||
|
|
||||||
old_bottle_spec.collector.each_key do |tag|
|
old_bottle_spec.collector.each_key do |tag|
|
||||||
old_value = old_bottle_spec.collector[tag].hexdigest
|
old_value = old_bottle_spec.collector[tag].hexdigest
|
||||||
new_value = new_bottle_hash["tags"][tag.to_s]
|
new_value = new_bottle_hash.dig("tags", tag.to_s)
|
||||||
if new_value.present?
|
if new_value.present?
|
||||||
mismatches << "sha256 => #{tag}"
|
mismatches << "sha256 => #{tag}"
|
||||||
else
|
else
|
||||||
|
|||||||
@ -173,6 +173,66 @@ describe Homebrew do
|
|||||||
"d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
"d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#merge_bottle_spec" do
|
||||||
|
it "allows new bottle hash to be empty" do
|
||||||
|
valid_keys = [:root_url, :prefix, :cellar, :rebuild, :sha256]
|
||||||
|
old_spec = BottleSpecification.new
|
||||||
|
old_spec.sha256("f59bc65c91e4e698f6f050e1efea0040f57372d4dcf0996cbb8f97ced320403b" => :big_sur)
|
||||||
|
expect { homebrew.merge_bottle_spec(valid_keys, old_spec, {}) }.not_to raise_error
|
||||||
|
end
|
||||||
|
|
||||||
|
it "checks for conflicting root URL" do
|
||||||
|
old_spec = BottleSpecification.new
|
||||||
|
old_spec.root_url("https://failbrew.bintray.com/bottles")
|
||||||
|
new_hash = { "root_url" => "https://testbrew.bintray.com/bottles" }
|
||||||
|
expect(homebrew.merge_bottle_spec([:root_url], old_spec, new_hash)).to eq [
|
||||||
|
['root_url: old: "https://failbrew.bintray.com/bottles", new: "https://testbrew.bintray.com/bottles"'],
|
||||||
|
[],
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "checks for conflicting prefix" do
|
||||||
|
old_spec = BottleSpecification.new
|
||||||
|
old_spec.prefix("/opt/failbrew")
|
||||||
|
new_hash = { "prefix" => "/opt/testbrew" }
|
||||||
|
expect(homebrew.merge_bottle_spec([:prefix], old_spec, new_hash)).to eq [
|
||||||
|
['prefix: old: "/opt/failbrew", new: "/opt/testbrew"'],
|
||||||
|
[],
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "checks for conflicting cellar" do
|
||||||
|
old_spec = BottleSpecification.new
|
||||||
|
old_spec.cellar("/opt/failbrew/Cellar")
|
||||||
|
new_hash = { "cellar" => "/opt/testbrew/Cellar" }
|
||||||
|
expect(homebrew.merge_bottle_spec([:cellar], old_spec, new_hash)).to eq [
|
||||||
|
['cellar: old: "/opt/failbrew/Cellar", new: "/opt/testbrew/Cellar"'],
|
||||||
|
[],
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "checks for conflicting rebuild number" do
|
||||||
|
old_spec = BottleSpecification.new
|
||||||
|
old_spec.rebuild(1)
|
||||||
|
new_hash = { "rebuild" => 2 }
|
||||||
|
expect(homebrew.merge_bottle_spec([:rebuild], old_spec, new_hash)).to eq [
|
||||||
|
['rebuild: old: "1", new: "2"'],
|
||||||
|
[],
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "checks for conflicting checksums" do
|
||||||
|
old_spec = BottleSpecification.new
|
||||||
|
old_spec.sha256("109c0cb581a7b5d84da36d84b221fb9dd0f8a927b3044d82611791c9907e202e" => :catalina)
|
||||||
|
old_spec.sha256("7571772bf7a0c9fe193e70e521318b53993bee6f351976c9b6e01e00d13d6c3f" => :mojave)
|
||||||
|
new_hash = { "tags" => { "catalina" => "ec6d7f08412468f28dee2be17ad8cd8b883b16b34329efcecce019b8c9736428" } }
|
||||||
|
expect(homebrew.merge_bottle_spec([:sha256], old_spec, new_hash)).to eq [
|
||||||
|
["sha256 => catalina"],
|
||||||
|
[{ "7571772bf7a0c9fe193e70e521318b53993bee6f351976c9b6e01e00d13d6c3f" => :mojave }],
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "brew bottle --merge", :integration_test, :needs_linux do
|
describe "brew bottle --merge", :integration_test, :needs_linux do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user