Add tests for formula migration warnings to default tap.

This commit is contained in:
Markus Reiter 2024-02-13 21:23:37 +01:00
parent c8058a3859
commit 228ebe0c32
No known key found for this signature in database
GPG Key ID: 245293B51702655B

View File

@ -528,4 +528,47 @@ describe Formulary do
expect(described_class.convert_to_string_or_symbol(":foo")).to eq :foo
end
end
describe "::loader_for" do
context "when not using the API" do
before do
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
end
context "when a formula is migrated to the default tap" do
let(:token) { "local-caffeine" }
let(:tap_migrations) do
{
token => default_tap.name,
}
end
let(:old_tap) { CoreCaskTap.instance }
let(:default_tap) { CoreTap.instance }
before do
old_tap.path.mkpath
(old_tap.path/"tap_migrations.json").write tap_migrations.to_json
old_tap.clear_cache
end
it "does not warn when loading the short token" do
expect do
described_class.loader_for(token)
end.not_to output.to_stderr
end
it "does not warn when loading the full token in the default tap" do
expect do
described_class.loader_for("#{default_tap}/#{token}")
end.not_to output.to_stderr
end
it "warns when loading the full token in the old tap" do
expect do
described_class.loader_for("#{old_tap}/#{token}")
end.to output(%r{Formula #{old_tap}/#{token} was renamed to #{token}\.}).to_stderr
end
end
end
end
end