mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00

The mirror probing spec file was moved to our regular suite, which runs
in parallel, recently. These specs rely on starting and stopping actual
servers in localhost, but this does not play nice with parallelization,
because a spec may kill the webserver another spec has created.
This commit moves mirror probing specs to not need to start servers in
localhost and do something more similar to what the other specs do.
ca9a19706f
68 lines
2.3 KiB
Ruby
68 lines
2.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "fetching dependencies with a not available mirror" do
|
|
before do
|
|
build_repo2
|
|
|
|
gemfile <<-G
|
|
source "https://gem.repo2"
|
|
gem 'weakling'
|
|
G
|
|
end
|
|
|
|
context "with a specific fallback timeout" do
|
|
before do
|
|
global_config("BUNDLE_MIRROR__HTTPS://GEM__REPO2/__FALLBACK_TIMEOUT/" => "true",
|
|
"BUNDLE_MIRROR__HTTPS://GEM__REPO2/" => "https://gem.mirror")
|
|
end
|
|
|
|
it "install a gem using the original uri when the mirror is not responding" do
|
|
bundle :install, env: { "BUNDLER_SPEC_FAKE_RESOLVE" => "gem.mirror" }, verbose: true
|
|
|
|
expect(out).to include("Installing weakling")
|
|
expect(out).to include("Bundle complete")
|
|
expect(the_bundle).to include_gems "weakling 0.0.3"
|
|
end
|
|
end
|
|
|
|
context "with a global fallback timeout" do
|
|
before do
|
|
global_config("BUNDLE_MIRROR__ALL__FALLBACK_TIMEOUT/" => "1",
|
|
"BUNDLE_MIRROR__ALL" => "https://gem.mirror")
|
|
end
|
|
|
|
it "install a gem using the original uri when the mirror is not responding" do
|
|
bundle :install, env: { "BUNDLER_SPEC_FAKE_RESOLVE" => "gem.mirror" }
|
|
|
|
expect(out).to include("Installing weakling")
|
|
expect(out).to include("Bundle complete")
|
|
expect(the_bundle).to include_gems "weakling 0.0.3"
|
|
end
|
|
end
|
|
|
|
context "with a specific mirror without a fallback timeout" do
|
|
before do
|
|
global_config("BUNDLE_MIRROR__HTTPS://GEM__REPO2/" => "https://gem.mirror")
|
|
end
|
|
|
|
it "fails to install the gem with a timeout error when the mirror is not responding" do
|
|
bundle :install, artifice: "compact_index_mirror_down", raise_on_error: false
|
|
|
|
expect(out).to be_empty
|
|
expect(err).to eq("Could not reach host gem.mirror. Check your network connection and try again.")
|
|
end
|
|
end
|
|
|
|
context "with a global mirror without a fallback timeout" do
|
|
before do
|
|
global_config("BUNDLE_MIRROR__ALL" => "https://gem.mirror")
|
|
end
|
|
|
|
it "fails to install the gem with a timeout error when the mirror is not responding" do
|
|
bundle :install, artifice: "compact_index_mirror_down", raise_on_error: false
|
|
|
|
expect(out).to be_empty
|
|
expect(err).to eq("Could not reach host gem.mirror. Check your network connection and try again.")
|
|
end
|
|
end
|
|
end
|