Skip to content

Commit

Permalink
Add tests for Formulary::loader_for migration warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Feb 13, 2024
1 parent d13628b commit 763c6df
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Library/Homebrew/test/formulary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -528,4 +528,47 @@ def formula_json_contents(extra_items = {})
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

0 comments on commit 763c6df

Please sign in to comment.