tap: add some tests
- Add tests for: - `Tap.each` - `Tap.installed` - `Tap.all` - `Tap#reverse_tap_migrations_renames` - `Tap.reverse_tap_migrations_renames`
This commit is contained in:
parent
d4a273443c
commit
e6a453a20d
@ -495,10 +495,52 @@ RSpec.describe Tap do
|
||||
expect(homebrew_foo_tap.config[:foo]).to be_nil
|
||||
end
|
||||
|
||||
describe "#each" do
|
||||
describe ".each" do
|
||||
it "returns an enumerator if no block is passed" do
|
||||
expect(described_class.each).to be_an_instance_of(Enumerator)
|
||||
end
|
||||
|
||||
context "when the core tap is not installed" do
|
||||
around do |example|
|
||||
FileUtils.rm_rf CoreTap.instance.path
|
||||
example.run
|
||||
ensure
|
||||
(CoreTap.instance.path/"Formula").mkpath
|
||||
end
|
||||
|
||||
it "includes the core tap with the api" do
|
||||
ENV.delete("HOMEBREW_NO_INSTALL_FROM_API")
|
||||
expect(described_class.to_a).to include(CoreTap.instance)
|
||||
end
|
||||
|
||||
it "omits the core tap without the api" do
|
||||
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
|
||||
expect(described_class.to_a).not_to include(CoreTap.instance)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe ".installed" do
|
||||
it "includes only installed taps" do
|
||||
expect(described_class.installed)
|
||||
.to contain_exactly(CoreTap.instance, described_class.fetch("homebrew/foo"))
|
||||
end
|
||||
end
|
||||
|
||||
describe ".all" do
|
||||
it "includes the core and cask taps by default", :needs_macos do
|
||||
expect(described_class.all).to contain_exactly(
|
||||
CoreTap.instance,
|
||||
CoreCaskTap.instance,
|
||||
described_class.fetch("homebrew/foo"),
|
||||
described_class.fetch("third-party/tap"),
|
||||
)
|
||||
end
|
||||
|
||||
it "includes the core tap and excludes the cask tap by default", :needs_linux do
|
||||
expect(described_class.all)
|
||||
.to contain_exactly(CoreTap.instance, described_class.fetch("homebrew/foo"))
|
||||
end
|
||||
end
|
||||
|
||||
describe "Formula Lists" do
|
||||
@ -520,6 +562,47 @@ RSpec.describe Tap do
|
||||
end
|
||||
end
|
||||
|
||||
describe "tap migration renames" do
|
||||
before do
|
||||
(path/"tap_migrations.json").write <<~JSON
|
||||
{
|
||||
"adobe-air-sdk": "homebrew/cask",
|
||||
"app-engine-go-32": "homebrew/cask/google-cloud-sdk",
|
||||
"app-engine-go-64": "homebrew/cask/google-cloud-sdk",
|
||||
"gimp": "homebrew/cask",
|
||||
"horndis": "homebrew/cask",
|
||||
"inkscape": "homebrew/cask",
|
||||
"schismtracker": "homebrew/cask/schism-tracker"
|
||||
}
|
||||
JSON
|
||||
end
|
||||
|
||||
describe "#reverse_tap_migration_renames" do
|
||||
it "returns the expected hash" do
|
||||
expect(homebrew_foo_tap.reverse_tap_migrations_renames).to eq({
|
||||
"homebrew/cask/google-cloud-sdk" => %w[app-engine-go-32 app-engine-go-64],
|
||||
"homebrew/cask/schism-tracker" => %w[schismtracker],
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
describe ".reverse_tap_migration_renames" do
|
||||
let(:cask_tap) { CoreCaskTap.instance }
|
||||
let(:core_tap) { CoreTap.instance }
|
||||
|
||||
it "returns expected renames" do
|
||||
[
|
||||
[cask_tap, "gimp", []],
|
||||
[core_tap, "schism-tracker", []],
|
||||
[cask_tap, "schism-tracker", %w[schismtracker]],
|
||||
[cask_tap, "google-cloud-sdk", %w[app-engine-go-32 app-engine-go-64]],
|
||||
].each do |tap, name, result|
|
||||
expect(described_class.reverse_tap_migrations_renames(tap, name)).to eq(result)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#audit_exceptions" do
|
||||
it "returns the audit_exceptions hash" do
|
||||
setup_tap_files
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user