Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-22 12:07:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-22 12:07:51 +0300
commit3ad11f24ca52d42694a8ce920a87ead6085d3f85 (patch)
treed5b664aafa7c2b65f470a700431d336d908c0ebc /spec/lib/gitlab/runtime_spec.rb
parent62fcb9ffa9e40db6f34e7dd0d36804d73ef01435 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/runtime_spec.rb')
-rw-r--r--spec/lib/gitlab/runtime_spec.rb101
1 files changed, 101 insertions, 0 deletions
diff --git a/spec/lib/gitlab/runtime_spec.rb b/spec/lib/gitlab/runtime_spec.rb
new file mode 100644
index 00000000000..ff8b383ba45
--- /dev/null
+++ b/spec/lib/gitlab/runtime_spec.rb
@@ -0,0 +1,101 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::Runtime do
+ context "when unknown" do
+ it "raises an exception when trying to identify" do
+ expect { subject.identify }.to raise_error(subject::UnknownProcessError)
+ end
+ end
+
+ context "on multiple matches" do
+ before do
+ stub_const('::Puma', double)
+ stub_const('::Rails::Console', double)
+ end
+
+ it "raises an exception when trying to identify" do
+ expect { subject.identify }.to raise_error(subject::AmbiguousProcessError)
+ end
+ end
+
+ context "puma" do
+ let(:puma_type) { double('::Puma') }
+
+ before do
+ stub_const('::Puma', puma_type)
+ end
+
+ it "identifies itself" do
+ expect(subject.identify).to eq(:puma)
+ expect(subject.puma?).to be(true)
+ end
+
+ it "does not identify as others" do
+ expect(subject.unicorn?).to be(false)
+ expect(subject.sidekiq?).to be(false)
+ expect(subject.console?).to be(false)
+ end
+ end
+
+ context "unicorn" do
+ let(:unicorn_type) { Module.new }
+ let(:unicorn_server_type) { Class.new }
+
+ before do
+ stub_const('::Unicorn', unicorn_type)
+ stub_const('::Unicorn::HttpServer', unicorn_server_type)
+ end
+
+ it "identifies itself" do
+ expect(subject.identify).to eq(:unicorn)
+ expect(subject.unicorn?).to be(true)
+ end
+
+ it "does not identify as others" do
+ expect(subject.puma?).to be(false)
+ expect(subject.sidekiq?).to be(false)
+ expect(subject.console?).to be(false)
+ end
+ end
+
+ context "sidekiq" do
+ let(:sidekiq_type) { double('::Sidekiq') }
+
+ before do
+ stub_const('::Sidekiq', sidekiq_type)
+ allow(sidekiq_type).to receive(:server?).and_return(true)
+ end
+
+ it "identifies itself" do
+ expect(subject.identify).to eq(:sidekiq)
+ expect(subject.sidekiq?).to be(true)
+ end
+
+ it "does not identify as others" do
+ expect(subject.unicorn?).to be(false)
+ expect(subject.puma?).to be(false)
+ expect(subject.console?).to be(false)
+ end
+ end
+
+ context "console" do
+ let(:console_type) { double('::Rails::Console') }
+
+ before do
+ stub_const('::Rails::Console', console_type)
+ end
+
+ it "identifies itself" do
+ expect(subject.identify).to eq(:console)
+ expect(subject.console?).to be(true)
+ end
+
+ it "does not identify as others" do
+ expect(subject.unicorn?).to be(false)
+ expect(subject.sidekiq?).to be(false)
+ expect(subject.puma?).to be(false)
+ end
+ end
+end