api/formula: Fix failing specs

- clear the formula API cache
- make the API cache directory
- fix stubbed return values (thanks Sorbet!)
This commit is contained in:
apainintheneck 2024-02-24 21:48:28 -08:00
parent 200fe2a6b7
commit bfe5e43ff4
2 changed files with 18 additions and 1 deletions

View File

@ -126,6 +126,7 @@ class Tap
@formula_dir = nil @formula_dir = nil
@cask_dir = nil @cask_dir = nil
@command_dir = nil @command_dir = nil
@formula_names = nil
@formula_files = nil @formula_files = nil
@cask_files = nil @cask_files = nil
@alias_dir = nil @alias_dir = nil

View File

@ -31,7 +31,23 @@ RSpec.describe "Internal Tap JSON -- Formula" do
allow(Homebrew::API).to receive(:fetch_json_api_file) allow(Homebrew::API).to receive(:fetch_json_api_file)
.with("internal/v3/homebrew-core.jws.json") .with("internal/v3/homebrew-core.jws.json")
.and_return(JSON.parse(internal_tap_json), false) .and_return([JSON.parse(internal_tap_json), false])
# `Tap.reverse_tap_migrations_renames` looks for renames in every
# tap so `CoreCaskTap.tap_migrations` gets called and tries to
# fetch stuff from the API. This just avoids errors.
allow(Homebrew::API).to receive(:fetch_json_api_file)
.with("cask_tap_migrations.jws.json", anything)
.and_return([{}, false])
# To allow `formula_names.txt` to be written to the cache.
(HOMEBREW_CACHE/"api").mkdir
Homebrew::API::Formula.clear_cache
end
after do
Homebrew::API::Formula.clear_cache
end end
it "loads tap aliases" do it "loads tap aliases" do