untap: use cachable to clear cached variables in tests

This commit is contained in:
apainintheneck 2024-03-12 21:07:33 -07:00
parent 11b67e04c2
commit eed7fd81a3

View File

@ -1,10 +1,14 @@
# typed: true # typed: true
# frozen_string_literal: true # frozen_string_literal: true
require "extend/cachable"
module Homebrew module Homebrew
# Helpers for the `brew untap` command. # Helpers for the `brew untap` command.
# @api private # @api private
module Untap module Untap
extend Cachable
# All installed formulae currently available in a tap by formula full name. # All installed formulae currently available in a tap by formula full name.
sig { params(tap: Tap).returns(T::Array[Formula]) } sig { params(tap: Tap).returns(T::Array[Formula]) }
def self.installed_formulae_for(tap:) def self.installed_formulae_for(tap:)
@ -26,7 +30,7 @@ module Homebrew
sig { returns(T::Set[String]) } sig { returns(T::Set[String]) }
def self.installed_formulae_names def self.installed_formulae_names
@installed_formulae_names ||= Formula.installed_formula_names.to_set.freeze cache[:installed_formulae_names] ||= Formula.installed_formula_names.to_set.freeze
end end
private_class_method :installed_formulae_names private_class_method :installed_formulae_names
@ -49,7 +53,7 @@ module Homebrew
sig { returns(T::Set[String]) } sig { returns(T::Set[String]) }
def self.installed_cask_tokens def self.installed_cask_tokens
@installed_cask_tokens ||= Cask::Caskroom.tokens.to_set.freeze cache[:installed_cask_tokens] ||= Cask::Caskroom.tokens.to_set.freeze
end end
private_class_method :installed_cask_tokens private_class_method :installed_cask_tokens
end end