debian-mirror-gitlab/spec/serializers/build_trace_entity_spec.rb

47 lines
1.1 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe BuildTraceEntity do
2019-12-21 20:55:43 +05:30
let(:build) { build_stubbed(:ci_build) }
let(:request) { double('request') }
let(:stream) do
Gitlab::Ci::Trace::Stream.new do
StringIO.new('the-trace')
end
end
let(:build_trace) do
2020-07-28 23:09:34 +05:30
Ci::BuildTrace.new(build: build, stream: stream, state: nil)
2019-12-21 20:55:43 +05:30
end
let(:entity) do
described_class.new(build_trace, request: request)
end
subject { entity.as_json }
2020-07-28 23:09:34 +05:30
it 'includes build attributes' do
expect(subject[:id]).to eq(build.id)
expect(subject[:status]).to eq(build.status)
expect(subject[:complete]).to eq(build.complete?)
2019-12-21 20:55:43 +05:30
end
2020-07-28 23:09:34 +05:30
it 'includes trace metadata' do
expect(subject).to include(:state)
expect(subject).to include(:append)
expect(subject).to include(:truncated)
expect(subject).to include(:offset)
expect(subject).to include(:size)
expect(subject).to include(:total)
2019-12-21 20:55:43 +05:30
end
2020-07-28 23:09:34 +05:30
it 'includes the trace content in json' do
2022-11-25 23:54:43 +05:30
expect(subject[:lines]).to eq(
[
{ offset: 0, content: [{ text: 'the-trace' }] }
])
2019-12-21 20:55:43 +05:30
end
end