Skip to content
代码片段 群组 项目
未验证 提交 0a1cd021 编辑于 作者: Sarah Yasonik's avatar Sarah Yasonik 提交者: GitLab
浏览文件

Add specs to validate that Internal Events CLI outputs valid definitions

上级 fc0f0cc4
No related branches found
No related tags found
无相关合并请求
...@@ -85,6 +85,29 @@ def wait_for_cli_completion ...@@ -85,6 +85,29 @@ def wait_for_cli_completion
end end
end end
shared_examples 'definition fixtures are valid' do |directory, schema_path|
let(:schema) { ::JSONSchemer.schema(Pathname(schema_path)) }
# The generator can return an invalid definition if the user skips the MR link
let(:expected_errors) { a_hash_including('data_pointer' => '/introduced_by_url', 'data' => 'TODO') }
it "for #{directory}", :aggregate_failures do
Dir[Rails.root.join('spec', 'fixtures', 'scripts', 'internal_events', directory, '*.yml')].each do |filepath|
attributes = YAML.safe_load(File.read(filepath))
errors = schema.validate(attributes).to_a
error_message = <<~TEXT
Unexpected validation errors in: #{filepath}
#{errors.map { |e| JSONSchemer::Errors.pretty(e) }.join("\n")}
TEXT
expect(errors).to contain_exactly(expected_errors), error_message
end
end
end
it_behaves_like 'definition fixtures are valid', 'events', 'config/events/schema.json'
it_behaves_like 'definition fixtures are valid', 'metrics', 'config/metrics/schema/base.json'
context 'when creating new events' do context 'when creating new events' do
YAML.safe_load(File.read('spec/fixtures/scripts/internal_events/new_events.yml')).each do |test_case| YAML.safe_load(File.read('spec/fixtures/scripts/internal_events/new_events.yml')).each do |test_case|
it_behaves_like 'creates the right defintion files', test_case['description'], test_case it_behaves_like 'creates the right defintion files', test_case['description'], test_case
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册