|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | RSpec.describe "fetching dependencies with a not available mirror" do |
4 | | - let(:mirror) { @mirror_uri } |
5 | | - let(:original) { @server_uri } |
6 | | - let(:server_port) { @server_port } |
7 | 4 | let(:host) { "127.0.0.1" } |
8 | 5 |
|
9 | 6 | before do |
|
20 | 17 |
|
21 | 18 | context "with a specific fallback timeout" do |
22 | 19 | before do |
23 | | - global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/__FALLBACK_TIMEOUT/" => "true", |
24 | | - "BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror) |
| 20 | + global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/__FALLBACK_TIMEOUT/" => "true", |
| 21 | + "BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/" => @mirror_uri) |
25 | 22 | end |
26 | 23 |
|
27 | 24 | it "install a gem using the original uri when the mirror is not responding" do |
28 | 25 | gemfile <<-G |
29 | | - source "#{original}" |
| 26 | + source "#{@server_uri}" |
30 | 27 | gem 'weakling' |
31 | 28 | G |
32 | 29 |
|
|
41 | 38 | context "with a global fallback timeout" do |
42 | 39 | before do |
43 | 40 | global_config("BUNDLE_MIRROR__ALL__FALLBACK_TIMEOUT/" => "1", |
44 | | - "BUNDLE_MIRROR__ALL" => mirror) |
| 41 | + "BUNDLE_MIRROR__ALL" => @mirror_uri) |
45 | 42 | end |
46 | 43 |
|
47 | 44 | it "install a gem using the original uri when the mirror is not responding" do |
48 | 45 | gemfile <<-G |
49 | | - source "#{original}" |
| 46 | + source "#{@server_uri}" |
50 | 47 | gem 'weakling' |
51 | 48 | G |
52 | 49 |
|
|
60 | 57 |
|
61 | 58 | context "with a specific mirror without a fallback timeout" do |
62 | 59 | before do |
63 | | - global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror) |
| 60 | + global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/" => @mirror_uri) |
64 | 61 | end |
65 | 62 |
|
66 | | - it "fails to install the gem with a timeout error" do |
| 63 | + it "fails to install the gem with a timeout error when the mirror is not responding" do |
67 | 64 | gemfile <<-G |
68 | | - source "#{original}" |
| 65 | + source "#{@server_uri}" |
69 | 66 | gem 'weakling' |
70 | 67 | G |
71 | 68 |
|
72 | 69 | bundle :install, artifice: nil, raise_on_error: false |
73 | 70 |
|
74 | | - expect(out).to include("Fetching source index from #{mirror}") |
| 71 | + expect(out).to include("Fetching source index from #{@mirror_uri}") |
75 | 72 |
|
76 | 73 | err_lines = err.split("\n") |
77 | | - expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <}) |
78 | | - expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <}) |
79 | | - expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <}) |
80 | | - expect(err_lines).to include(%r{\ACould not fetch specs from #{mirror}/ due to underlying error <}) |
| 74 | + expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <}) |
| 75 | + expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <}) |
| 76 | + expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <}) |
| 77 | + expect(err_lines).to include(%r{\ACould not fetch specs from #{@mirror_uri}/ due to underlying error <}) |
81 | 78 | end |
82 | 79 | end |
83 | 80 |
|
84 | 81 | context "with a global mirror without a fallback timeout" do |
85 | 82 | before do |
86 | | - global_config("BUNDLE_MIRROR__ALL" => mirror) |
| 83 | + global_config("BUNDLE_MIRROR__ALL" => @mirror_uri) |
87 | 84 | end |
88 | 85 |
|
89 | | - it "fails to install the gem with a timeout error" do |
| 86 | + it "fails to install the gem with a timeout error when the mirror is not responding" do |
90 | 87 | gemfile <<-G |
91 | | - source "#{original}" |
| 88 | + source "#{@server_uri}" |
92 | 89 | gem 'weakling' |
93 | 90 | G |
94 | 91 |
|
95 | 92 | bundle :install, artifice: nil, raise_on_error: false |
96 | 93 |
|
97 | | - expect(out).to include("Fetching source index from #{mirror}") |
| 94 | + expect(out).to include("Fetching source index from #{@mirror_uri}") |
98 | 95 |
|
99 | 96 | err_lines = err.split("\n") |
100 | | - expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <}) |
101 | | - expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <}) |
102 | | - expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <}) |
103 | | - expect(err_lines).to include(%r{\ACould not fetch specs from #{mirror}/ due to underlying error <}) |
| 97 | + expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <}) |
| 98 | + expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <}) |
| 99 | + expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <}) |
| 100 | + expect(err_lines).to include(%r{\ACould not fetch specs from #{@mirror_uri}/ due to underlying error <}) |
104 | 101 | end |
105 | 102 | end |
106 | 103 |
|
107 | 104 | def setup_server |
108 | 105 | @server_port = find_unused_port |
109 | 106 | @server_uri = "http://#{host}:#{@server_port}" |
110 | 107 |
|
111 | | - require_relative "../../support/artifice/endpoint" |
| 108 | + require_relative "../../support/artifice/compact_index" |
112 | 109 | require_relative "../../support/silent_logger" |
113 | 110 |
|
114 | 111 | require "rackup/server" |
115 | 112 |
|
116 | 113 | @server_thread = Thread.new do |
117 | | - Rackup::Server.start(app: Endpoint, |
| 114 | + Rackup::Server.start(app: CompactIndexAPI, |
118 | 115 | Host: host, |
119 | 116 | Port: @server_port, |
120 | 117 | server: "webrick", |
|
0 commit comments