2017-02-26 13:22:16 +01:00
|
|
|
require "cmd/update-report"
|
|
|
|
|
2018-08-05 18:23:08 +02:00
|
|
|
describe "brew update-report" do
|
|
|
|
describe "::migrate_cache_entries_to_double_dashes" do
|
|
|
|
let(:legacy_cache_file) { HOMEBREW_CACHE/"foo-1.2.3.tar.gz" }
|
|
|
|
let(:renamed_cache_file) { HOMEBREW_CACHE/"foo--1.2.3.tar.gz" }
|
2017-02-26 13:22:16 +01:00
|
|
|
|
2018-08-05 18:23:08 +02:00
|
|
|
before(:each) do
|
|
|
|
FileUtils.touch legacy_cache_file
|
2017-02-26 13:22:16 +01:00
|
|
|
end
|
|
|
|
|
2018-08-05 18:23:08 +02:00
|
|
|
it "moves old files to use double dashes when upgrading from <= 1.7.1" do
|
|
|
|
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
|
2017-02-26 13:22:16 +01:00
|
|
|
|
2018-08-05 18:23:08 +02:00
|
|
|
expect(legacy_cache_file).not_to exist
|
|
|
|
expect(renamed_cache_file).to exist
|
2017-02-26 13:22:16 +01:00
|
|
|
end
|
|
|
|
|
2018-08-06 12:23:37 +02:00
|
|
|
context "when the formula name contains dashes" do
|
|
|
|
let(:legacy_cache_file) { HOMEBREW_CACHE/"foo-bar-1.2.3.tar.gz" }
|
|
|
|
let(:renamed_cache_file) { HOMEBREW_CACHE/"foo-bar--1.2.3.tar.gz" }
|
|
|
|
|
|
|
|
it "does not introduce extra double dashes when called multiple times" do
|
|
|
|
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
|
|
|
|
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
|
|
|
|
|
|
|
|
expect(legacy_cache_file).not_to exist
|
|
|
|
expect(renamed_cache_file).to exist
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when the file is a patch and the formula name contains dashes" do
|
|
|
|
let(:legacy_cache_file) { HOMEBREW_CACHE/"foo-bar-patch--1.2.3.tar.gz" }
|
|
|
|
let(:renamed_cache_file) { HOMEBREW_CACHE/"foo-bar--patch--1.2.3.tar.gz" }
|
|
|
|
|
|
|
|
it "does not introduce extra double dashes when called multiple times" do
|
|
|
|
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
|
|
|
|
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.1"))
|
|
|
|
|
|
|
|
expect(legacy_cache_file).not_to exist
|
|
|
|
expect(renamed_cache_file).to exist
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-05 18:23:08 +02:00
|
|
|
it "does not move files if upgrading from > 1.7.1" do
|
|
|
|
Homebrew.migrate_cache_entries_to_double_dashes(Version.new("1.7.2"))
|
2017-02-26 13:22:16 +01:00
|
|
|
|
2018-08-05 18:23:08 +02:00
|
|
|
expect(legacy_cache_file).to exist
|
|
|
|
expect(renamed_cache_file).not_to exist
|
2017-02-26 13:22:16 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|