debian-mirror-gitlab/spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb

74 lines
2.7 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::GitalyClient::ConflictFilesStitcher do
2018-03-17 18:26:18 +05:30
describe 'enumeration' do
it 'combines segregated ConflictFile messages together' do
target_project = create(:project, :repository)
target_repository = target_project.repository.raw
target_gitaly_repository = target_repository.gitaly_repository
2021-10-27 15:23:28 +05:30
ancestor_path_1 = 'ancestor/path/1'
2018-03-17 18:26:18 +05:30
our_path_1 = 'our/path/1'
their_path_1 = 'their/path/1'
our_mode_1 = 0744
commit_oid_1 = 'f00'
content_1 = 'content of the first file'
2021-10-27 15:23:28 +05:30
ancestor_path_2 = 'ancestor/path/2'
2018-03-17 18:26:18 +05:30
our_path_2 = 'our/path/2'
their_path_2 = 'their/path/2'
our_mode_2 = 0600
commit_oid_2 = 'ba7'
content_2 = 'content of the second file'
2021-10-27 15:23:28 +05:30
header_1 = double(
repository: target_gitaly_repository,
commit_oid: commit_oid_1,
ancestor_path: ancestor_path_1,
our_path: our_path_1,
their_path: their_path_1,
our_mode: our_mode_1
)
header_2 = double(
repository: target_gitaly_repository,
commit_oid: commit_oid_2,
ancestor_path: ancestor_path_2,
our_path: our_path_2,
their_path: their_path_2,
our_mode: our_mode_2
)
2018-03-17 18:26:18 +05:30
messages = [
double(files: [double(header: header_1), double(header: nil, content: content_1[0..5])]),
2022-01-26 12:08:38 +05:30
double(files: [double(header: nil, content: content_1[6..])]),
2018-03-17 18:26:18 +05:30
double(files: [double(header: header_2)]),
double(files: [double(header: nil, content: content_2[0..5]), double(header: nil, content: content_2[6..10])]),
2022-01-26 12:08:38 +05:30
double(files: [double(header: nil, content: content_2[11..])])
2018-03-17 18:26:18 +05:30
]
2019-12-21 20:55:43 +05:30
conflict_files = described_class.new(messages, target_repository.gitaly_repository).to_a
2018-03-17 18:26:18 +05:30
expect(conflict_files.size).to be(2)
expect(conflict_files[0].content).to eq(content_1)
2021-10-27 15:23:28 +05:30
expect(conflict_files[0].ancestor_path).to eq(ancestor_path_1)
2018-03-17 18:26:18 +05:30
expect(conflict_files[0].their_path).to eq(their_path_1)
expect(conflict_files[0].our_path).to eq(our_path_1)
expect(conflict_files[0].our_mode).to be(our_mode_1)
expect(conflict_files[0].repository).to eq(target_repository)
expect(conflict_files[0].commit_oid).to eq(commit_oid_1)
expect(conflict_files[1].content).to eq(content_2)
2021-10-27 15:23:28 +05:30
expect(conflict_files[1].ancestor_path).to eq(ancestor_path_2)
2018-03-17 18:26:18 +05:30
expect(conflict_files[1].their_path).to eq(their_path_2)
expect(conflict_files[1].our_path).to eq(our_path_2)
expect(conflict_files[1].our_mode).to be(our_mode_2)
expect(conflict_files[1].repository).to eq(target_repository)
expect(conflict_files[1].commit_oid).to eq(commit_oid_2)
end
end
end