2019-10-08 05:06:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe TestSuiteEntity do
|
2020-04-21 11:21:10 -04:00
|
|
|
let(:pipeline) { create(:ci_pipeline, :with_test_reports) }
|
|
|
|
let(:test_suite) { pipeline.test_reports.test_suites.each_value.first }
|
|
|
|
let(:entity) { described_class.new(test_suite) }
|
2019-10-08 05:06:09 -04:00
|
|
|
|
|
|
|
describe '#as_json' do
|
|
|
|
subject(:as_json) { entity.as_json }
|
|
|
|
|
|
|
|
it 'contains the suite name' do
|
2020-04-21 11:21:10 -04:00
|
|
|
expect(as_json[:name]).to be_present
|
2019-10-08 05:06:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the total time' do
|
2020-04-21 11:21:10 -04:00
|
|
|
expect(as_json[:total_time]).to be_present
|
2019-10-08 05:06:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the counts' do
|
2020-04-21 11:21:10 -04:00
|
|
|
expect(as_json[:total_count]).to eq(4)
|
|
|
|
expect(as_json[:success_count]).to eq(2)
|
|
|
|
expect(as_json[:failed_count]).to eq(2)
|
|
|
|
expect(as_json[:skipped_count]).to eq(0)
|
|
|
|
expect(as_json[:error_count]).to eq(0)
|
2019-10-08 05:06:09 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the test cases' do
|
|
|
|
expect(as_json[:test_cases].count).to eq(4)
|
|
|
|
end
|
2020-04-21 11:21:10 -04:00
|
|
|
|
|
|
|
it 'contains an empty error message' do
|
|
|
|
expect(as_json[:suite_error]).to be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a suite error' do
|
|
|
|
before do
|
|
|
|
test_suite.set_suite_error('a really bad error')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the suite name' do
|
|
|
|
expect(as_json[:name]).to be_present
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'contains the total time' do
|
|
|
|
expect(as_json[:total_time]).to be_present
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns all the counts as 0' do
|
|
|
|
expect(as_json[:total_count]).to eq(0)
|
|
|
|
expect(as_json[:success_count]).to eq(0)
|
|
|
|
expect(as_json[:failed_count]).to eq(0)
|
|
|
|
expect(as_json[:skipped_count]).to eq(0)
|
|
|
|
expect(as_json[:error_count]).to eq(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns no test cases' do
|
|
|
|
expect(as_json[:test_cases]).to be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a suite error' do
|
|
|
|
expect(as_json[:suite_error]).to eq('a really bad error')
|
|
|
|
end
|
|
|
|
end
|
2019-10-08 05:06:09 -04:00
|
|
|
end
|
|
|
|
end
|