debian-mirror-gitlab/spec/lib/gitlab/ci/ansi2json/result_spec.rb

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

43 lines
951 B
Ruby
Raw Permalink Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'fast_spec_helper'
2020-01-01 13:55:28 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Ci::Ansi2json::Result do
2020-01-01 13:55:28 +05:30
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
2021-02-22 17:27:13 +05:30
subject { described_class.new(**params) }
2020-01-01 13:55:28 +05:30
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