Welcome to mirror list, hosted at ThFree Co, Russian Federation.

build_trace_spec.rb « ci « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3beca0565c68d4417f7576785039e331f697a0ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Ci::BuildTrace do
  let(:build) { build_stubbed(:ci_build) }
  let(:state) { nil }
  let(:data) { StringIO.new('the-stream') }

  let(:stream) do
    Gitlab::Ci::Trace::Stream.new { data }
  end

  subject { described_class.new(build: build, stream: stream, state: state) }

  shared_examples 'delegates methods' do
    it { is_expected.to delegate_method(:state).to(:trace) }
    it { is_expected.to delegate_method(:append).to(:trace) }
    it { is_expected.to delegate_method(:truncated).to(:trace) }
    it { is_expected.to delegate_method(:offset).to(:trace) }
    it { is_expected.to delegate_method(:size).to(:trace) }
    it { is_expected.to delegate_method(:total).to(:trace) }
    it { is_expected.to delegate_method(:id).to(:build).with_prefix }
    it { is_expected.to delegate_method(:status).to(:build).with_prefix }
    it { is_expected.to delegate_method(:complete?).to(:build).with_prefix }
  end

  it_behaves_like 'delegates methods'

  it 'returns formatted trace' do
    expect(subject.lines).to eq([
      { offset: 0, content: [{ text: 'the-stream' }] }
    ])
  end
end