diff options
Diffstat (limited to 'spec/tasks/gitlab/packages')
-rw-r--r-- | spec/tasks/gitlab/packages/events_rake_spec.rb | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/spec/tasks/gitlab/packages/events_rake_spec.rb b/spec/tasks/gitlab/packages/events_rake_spec.rb index ac28f9b5fc2..a485dc2ce58 100644 --- a/spec/tasks/gitlab/packages/events_rake_spec.rb +++ b/spec/tasks/gitlab/packages/events_rake_spec.rb @@ -7,32 +7,49 @@ RSpec.describe 'gitlab:packages:events namespace rake task' do Rake.application.rake_require 'tasks/gitlab/packages/events' end - describe 'generate' do - subject do - file = double('file') - yml_file = nil + subject do + file = double('file') + yml_file = nil - allow(file).to receive(:<<) { |contents| yml_file = contents } - allow(File).to receive(:open).and_yield(file) + allow(file).to receive(:<<) { |contents| yml_file = contents } + allow(File).to receive(:open).and_yield(file) - run_rake_task('gitlab:packages:events:generate') + run_rake_task("gitlab:packages:events:#{task}") - YAML.safe_load(yml_file) - end + YAML.safe_load(yml_file) + end + + describe 'generate_unique' do + let(:task) { 'generate_unique' } it 'excludes guest events' do expect(subject.find { |event| event['name'].include?("guest") }).to be_nil end - ::Packages::Event::EVENT_SCOPES.keys.each do |event_scope| - it "includes includes `#{event_scope}` scope" do + Packages::Event::EVENT_SCOPES.keys.each do |event_scope| + it "includes `#{event_scope}` scope" do expect(subject.find { |event| event['name'].include?(event_scope) }).not_to be_nil end end it 'excludes some event types' do - expect(subject.find { |event| event['name'].include?("search_package") }).to be_nil - expect(subject.find { |event| event['name'].include?("list_package") }).to be_nil + expect(subject.grep(/search_package/)).to be_empty + expect(subject.grep(/list_package/)).to be_empty + end + end + + describe 'generate_guest' do + let(:task) { 'generate_guest' } + + Packages::Event::EVENT_SCOPES.keys.each do |event_scope| + it "includes `#{event_scope}` scope" do + expect(subject.find { |event| event.include?(event_scope) }).not_to be_nil + end + end + + it 'excludes some event types' do + expect(subject.find { |event| event.include?("search_package") }).to be_nil + expect(subject.find { |event| event.include?("list_package") }).to be_nil end end end |