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:
authorMark Lapierre <mlapierre@gitlab.com>2019-02-11 12:04:59 +0300
committerRamya Authappan <rauthappan@gitlab.com>2019-02-11 12:04:59 +0300
commit97265d39e72cbb32468a3f1d671820528af02a8b (patch)
tree03c7d01e071ce0843987ad6f1eb96234fa20074a /qa/spec/resource
parent25af9032750c215860829fecb196da1e1c5ace6b (diff)
[CE] Improve `wait_for_push`
Diffstat (limited to 'qa/spec/resource')
-rw-r--r--qa/spec/resource/base_spec.rb2
-rw-r--r--qa/spec/resource/events/base_spec.rb29
-rw-r--r--qa/spec/resource/events/project_spec.rb69
3 files changed, 99 insertions, 1 deletions
diff --git a/qa/spec/resource/base_spec.rb b/qa/spec/resource/base_spec.rb
index a2a3ad01749..4a6b76c869f 100644
--- a/qa/spec/resource/base_spec.rb
+++ b/qa/spec/resource/base_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
describe QA::Resource::Base do
- include Support::StubENV
+ include Helpers::StubENV
let(:resource) { spy('resource') }
let(:location) { 'http://location' }
diff --git a/qa/spec/resource/events/base_spec.rb b/qa/spec/resource/events/base_spec.rb
new file mode 100644
index 00000000000..9cdf4785092
--- /dev/null
+++ b/qa/spec/resource/events/base_spec.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+describe QA::Resource::Events::Base do
+ let(:resource) do
+ Class.new(QA::Resource::Base) do
+ def api_get_path
+ '/foo'
+ end
+ end
+ end
+
+ subject { resource.tap { |f| f.include(described_class) }.new }
+
+ describe "#events" do
+ it 'fetches all events when called without parameters' do
+ allow(subject).to receive(:parse_body).and_return('returned')
+
+ expect(subject).to receive(:api_get_from).with('/foo/events')
+ expect(subject.events).to eq('returned')
+ end
+
+ it 'fetches events with a specified action type' do
+ allow(subject).to receive(:parse_body).and_return('returned')
+
+ expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
+ expect(subject.events(action: 'pushed')).to eq('returned')
+ end
+ end
+end
diff --git a/qa/spec/resource/events/project_spec.rb b/qa/spec/resource/events/project_spec.rb
new file mode 100644
index 00000000000..b3efdb518f3
--- /dev/null
+++ b/qa/spec/resource/events/project_spec.rb
@@ -0,0 +1,69 @@
+# frozen_string_literal: true
+
+describe QA::Resource::Events::Project do
+ let(:resource) do
+ Class.new(QA::Resource::Base) do
+ def api_get_path
+ '/foo'
+ end
+ end
+ end
+ let(:all_events) do
+ [
+ {
+ "action_name": "pushed",
+ "push_data": {
+ "commit_title": "foo commit"
+ }
+ },
+ {
+ "action_name": "pushed",
+ "push_data": {
+ "ref": "master"
+ }
+ },
+ {
+ "action_name": "pushed",
+ "push_data": {
+ "ref": "another-branch"
+ }
+ }
+ ]
+ end
+
+ before do
+ allow(subject).to receive(:max_wait).and_return(0.01)
+ allow(subject).to receive(:parse_body).and_return(all_events)
+ end
+
+ subject { resource.tap { |f| f.include(described_class) }.new }
+
+ describe "#wait_for_push" do
+ it 'waits for a push with a specified commit message' do
+ expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
+ expect { subject.wait_for_push('foo commit') }.not_to raise_error
+ end
+
+ it 'raises an error if a push with the specified commit message is not found' do
+ expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed').at_least(:once)
+ expect { subject.wait_for_push('bar') }.to raise_error(QA::Resource::Events::EventNotFoundError)
+ end
+ end
+
+ describe "#wait_for_push_new_branch" do
+ it 'waits for a push to master if no branch is given' do
+ expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
+ expect { subject.wait_for_push_new_branch }.not_to raise_error
+ end
+
+ it 'waits for a push to the given branch' do
+ expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
+ expect { subject.wait_for_push_new_branch('another-branch') }.not_to raise_error
+ end
+
+ it 'raises an error if a push with the specified branch is not found' do
+ expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed').at_least(:once)
+ expect { subject.wait_for_push_new_branch('bar') }.to raise_error(QA::Resource::Events::EventNotFoundError)
+ end
+ end
+end