Unpin bundler, fix gem installer tests (#13762)

Fix gem installer tests to enable unpinning the version of bundler

This commit removes changes the gem installer to use real gems, rather than
use `allow_instance_of` during testing, which appears to be problematic with the
latest version of bundler
This commit is contained in:
Rob Bavey 2022-02-11 09:13:11 -05:00 committed by GitHub
parent e38b25ced3
commit aceb682f18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 11 deletions

View file

@ -307,7 +307,7 @@ tasks.register("installBundler") {
dependsOn assemblyDeps dependsOn assemblyDeps
outputs.files file("${projectDir}/vendor/bundle/jruby/2.5.0/bin/bundle") outputs.files file("${projectDir}/vendor/bundle/jruby/2.5.0/bin/bundle")
doLast { doLast {
gem(projectDir, buildDir, "bundler", "= 2.3.6", "${projectDir}/vendor/bundle/jruby/2.5.0") gem(projectDir, buildDir, "bundler", "~> 2", "${projectDir}/vendor/bundle/jruby/2.5.0")
} }
} }
@ -435,7 +435,7 @@ tasks.register("installIntegrationTestBundler"){
dependsOn unpackTarDistribution dependsOn unpackTarDistribution
outputs.files file("${qaBundleBin}") outputs.files file("${qaBundleBin}")
doLast { doLast {
gem(projectDir, buildDir, "bundler", "= 2.3.6", qaBundledGemPath) gem(projectDir, buildDir, "bundler", "~> 2", qaBundledGemPath)
} }
} }

View file

@ -4,7 +4,6 @@ Gem::Specification.new do |spec|
spec.version = "0.0.1" spec.version = "0.0.1"
spec.authors = ["Elastic"] spec.authors = ["Elastic"]
spec.email = ["info@elastic.co"] spec.email = ["info@elastic.co"]
spec.summary = "a summary" spec.summary = "a summary"
spec.description = "a description" spec.description = "a description"
spec.homepage = "https://elastic.co" spec.homepage = "https://elastic.co"

View file

@ -0,0 +1,12 @@
# coding: utf-8
Gem::Specification.new do |spec|
spec.name = "logstash-input-packtest_pim"
spec.version = "0.0.1"
spec.authors = ["Elastic"]
spec.email = ["info@elastic.co"]
spec.post_install_message = "Hello from the friendly pack"
spec.summary = "a summary"
spec.description = "a description"
spec.homepage = "https://elastic.co"
spec.add_runtime_dependency "logstash-input-packtestdep"
end

View file

@ -46,9 +46,7 @@ describe LogStash::PluginManager::GemInstaller do
let(:message) { "Hello from the friendly pack" } let(:message) { "Hello from the friendly pack" }
context "when present" do context "when present" do
before do let(:plugin_name) { 'logstash-input-packtest_pim-0.0.1' }
allow_any_instance_of(::Gem::Specification).to receive(:post_install_message).and_return(message)
end
context "when we want the message" do context "when we want the message" do
it "display the message" do it "display the message" do
@ -64,7 +62,7 @@ describe LogStash::PluginManager::GemInstaller do
end end
context "when not present" do context "when not present" do
context "when we want the message" do context "when we don't want the message" do
it "doesn't display the message" do it "doesn't display the message" do
expect(LogStash::PluginManager.ui).not_to receive(:info).with(message) expect(LogStash::PluginManager.ui).not_to receive(:info).with(message)
subject.install(simple_gem, true, temporary_gem_home) subject.install(simple_gem, true, temporary_gem_home)

View file

@ -29,8 +29,8 @@ describe LogStash::PluginManager::PackInstaller::Pack do
end end
it "returns the plugins" do it "returns the plugins" do
expect(subject.plugins.size).to eq(1) expect(subject.plugins.size).to eq(2)
expect(subject.plugins.collect(&:name)).to include("logstash-input-packtest") expect(subject.plugins.collect(&:name)).to include("logstash-input-packtest_pim", "logstash-input-packtest")
end end
it "returns the dependencies" do it "returns the dependencies" do
@ -39,8 +39,8 @@ describe LogStash::PluginManager::PackInstaller::Pack do
end end
it "returns all the gems" do it "returns all the gems" do
expect(subject.gems.size).to eq(2) expect(subject.gems.size).to eq(3)
expect(subject.gems.collect(&:name)).to include("logstash-input-packtest", "logstash-input-packtestdep") expect(subject.gems.collect(&:name)).to include("logstash-input-packtest", "logstash-input-packtest_pim", "logstash-input-packtestdep")
end end
end end