debian-mirror-gitlab/spec/models/ci/build_report_result_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
1.9 KiB
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Ci::BuildReportResult do
2020-06-23 00:09:42 +05:30
let(:build_report_result) { build(:ci_build_report_result, :with_junit_success) }
2022-03-02 08:16:31 +05:30
it_behaves_like 'cleanup by a loose foreign key' do
let!(:parent) { create(:project) }
let!(:model) { create(:ci_build_report_result, project: parent) }
end
2020-06-23 00:09:42 +05:30
describe 'associations' do
it { is_expected.to belong_to(:build) }
it { is_expected.to belong_to(:project) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:build) }
context 'when attributes are valid' do
it 'returns no errors' do
expect(build_report_result).to be_valid
end
end
context 'when data is invalid' do
it 'returns errors' do
build_report_result.data = { invalid: 'data' }
expect(build_report_result).to be_invalid
expect(build_report_result.errors.full_messages).to eq(["Data must be a valid json schema"])
end
end
end
describe '#tests_name' do
it 'returns the suite name' do
expect(build_report_result.tests_name).to eq("rspec")
end
end
describe '#tests_duration' do
it 'returns the suite duration' do
expect(build_report_result.tests_duration).to eq(0.42)
end
end
describe '#tests_success' do
it 'returns the success count' do
expect(build_report_result.tests_success).to eq(2)
end
end
describe '#tests_failed' do
it 'returns the failed count' do
expect(build_report_result.tests_failed).to eq(0)
end
end
describe '#tests_errored' do
it 'returns the errored count' do
expect(build_report_result.tests_errored).to eq(0)
end
end
describe '#tests_skipped' do
it 'returns the skipped count' do
expect(build_report_result.tests_skipped).to eq(0)
end
end
end