Control for CPU type and Rosetta in os_arch_prefix_ci tests

This commit is contained in:
Rylan Polster 2021-12-03 22:29:10 -05:00
parent e2fc14b0b7
commit b58551cd67
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64

View File

@ -11,12 +11,28 @@ describe Utils::Analytics do
described_class.clear_os_arch_prefix_ci
end
it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix" do
it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix on intel" do
allow(Hardware::CPU).to receive(:type).and_return(:intel)
allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false)
allow(Homebrew).to receive(:default_prefix?).and_return(false)
arch = ", #{described_class.arch_label}" if described_class.arch_label.present?
expected = "#{OS_VERSION}#{arch}, #{described_class.custom_prefix_label}"
expect(described_class.os_arch_prefix_ci).to include(expected)
expected = "#{OS_VERSION}, #{described_class.custom_prefix_label}"
expect(described_class.os_arch_prefix_ci).to eq expected
end
it 'returns OS_VERSION, "ARM" and prefix when HOMEBREW_PREFIX is a custom prefix on arm' do
allow(Hardware::CPU).to receive(:type).and_return(:arm)
allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false)
allow(Homebrew).to receive(:default_prefix?).and_return(false)
expected = "#{OS_VERSION}, ARM, #{described_class.custom_prefix_label}"
expect(described_class.os_arch_prefix_ci).to eq expected
end
it 'returns OS_VERSION, "Rosetta" and prefix when HOMEBREW_PREFIX is a custom prefix using Rosetta' do
allow(Hardware::CPU).to receive(:type).and_return(:intel)
allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(true)
allow(Homebrew).to receive(:default_prefix?).and_return(false)
expected = "#{OS_VERSION}, Rosetta, #{described_class.custom_prefix_label}"
expect(described_class.os_arch_prefix_ci).to eq expected
end
it "does not include prefix when HOMEBREW_PREFIX is the default prefix" do