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

result_spec.rb « ansi2json « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5b7b54814005f2284f1541b7d556583a200c64b5 (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
36
37
38
39
40
41
42
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::Ci::Ansi2json::Result do
  let(:stream) { StringIO.new('hello') }
  let(:state) { Gitlab::Ci::Ansi2json::State.new(nil, stream.size) }
  let(:offset) { 0 }
  let(:params) do
    { lines: [], state: state, append: false, truncated: false, offset: offset, stream: stream }
  end

  subject { described_class.new(params) }

  describe '#size' do
    before do
      stream.seek(5) # move stream cursor to the end
    end

    context 'when offset is at the start' do
      let(:offset) { 0 }

      it 'returns the full size' do
        expect(subject.size).to eq(5)
      end
    end

    context 'when offset is not zero' do
      let(:offset) { 2 }

      it 'returns the remaining size' do
        expect(subject.size).to eq(3)
      end
    end
  end

  describe '#total' do
    it 'returns size of stread' do
      expect(subject.total).to eq(5)
    end
  end
end