Commit 57161278 authored by Sean Arnold's avatar Sean Arnold

Merge branch 'fix-schema-pipeline-created-event' into 'master'

Require pipeline_id in Ci::PipelineCreatedEvent

See merge request gitlab-org/gitlab!82482
parents 2b0f268d 3465fda1
......@@ -5,6 +5,7 @@ module Ci
def schema
{
'type' => 'object',
'required' => ['pipeline_id'],
'properties' => {
'pipeline_id' => { 'type' => 'integer' }
}
......
......@@ -293,8 +293,7 @@ in the `handle_event` method of the subscriber worker.
## Testing
A publisher doesn't must care what subscribed to the event being published. The publisher's
responsibility is to ensure that the event is published correctly.
The publisher's responsibility is to ensure that the event is published correctly.
To test that an event has been published correctly, we can use the RSpec matcher `:publish_event`:
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::PipelineCreatedEvent do
using RSpec::Parameterized::TableSyntax
where(:data, :valid) do
{ pipeline_id: 1 } | true
{ pipeline_id: nil } | false
{ pipeline_id: "test" } | false
{} | false
{ job_id: 1 } | false
end
with_them do
let(:event) { described_class.new(data: data) }
it 'validates the data according to the schema' do
if valid
expect { event }.not_to raise_error
else
expect { event }.to raise_error(Gitlab::EventStore::InvalidEvent)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment