Fix analytics string to test for CI

This commit is contained in:
Nipunn Koorapati 2021-12-04 12:29:31 -05:00
parent b58551cd67
commit 30c4663066

View File

@ -11,11 +11,13 @@ describe Utils::Analytics do
described_class.clear_os_arch_prefix_ci described_class.clear_os_arch_prefix_ci
end end
ci = ", CI" if ENV["CI"]
it "returns OS_VERSION and prefix when HOMEBREW_PREFIX is a custom prefix on intel" 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(:type).and_return(:intel)
allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false) allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false)
allow(Homebrew).to receive(:default_prefix?).and_return(false) allow(Homebrew).to receive(:default_prefix?).and_return(false)
expected = "#{OS_VERSION}, #{described_class.custom_prefix_label}" expected = "#{OS_VERSION}, #{described_class.custom_prefix_label}#{ci}"
expect(described_class.os_arch_prefix_ci).to eq expected expect(described_class.os_arch_prefix_ci).to eq expected
end end
@ -23,7 +25,7 @@ describe Utils::Analytics do
allow(Hardware::CPU).to receive(:type).and_return(:arm) allow(Hardware::CPU).to receive(:type).and_return(:arm)
allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false) allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(false)
allow(Homebrew).to receive(:default_prefix?).and_return(false) allow(Homebrew).to receive(:default_prefix?).and_return(false)
expected = "#{OS_VERSION}, ARM, #{described_class.custom_prefix_label}" expected = "#{OS_VERSION}, ARM, #{described_class.custom_prefix_label}#{ci}"
expect(described_class.os_arch_prefix_ci).to eq expected expect(described_class.os_arch_prefix_ci).to eq expected
end end
@ -31,7 +33,7 @@ describe Utils::Analytics do
allow(Hardware::CPU).to receive(:type).and_return(:intel) allow(Hardware::CPU).to receive(:type).and_return(:intel)
allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(true) allow(Hardware::CPU).to receive(:in_rosetta2?).and_return(true)
allow(Homebrew).to receive(:default_prefix?).and_return(false) allow(Homebrew).to receive(:default_prefix?).and_return(false)
expected = "#{OS_VERSION}, Rosetta, #{described_class.custom_prefix_label}" expected = "#{OS_VERSION}, Rosetta, #{described_class.custom_prefix_label}#{ci}"
expect(described_class.os_arch_prefix_ci).to eq expected expect(described_class.os_arch_prefix_ci).to eq expected
end end