Skip to content

Commit

Permalink
Add remote_name constant to point_to_same_commit? test
Browse files Browse the repository at this point in the history
  • Loading branch information
iangmaia committed Sep 9, 2024
1 parent 9d1f017 commit 36cd7bc
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions spec/git_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
expect(described_class.has_git_lfs?).to be false
end

context('commit(message:, files:)') do
describe 'commit(message:, files:)' do
before do
allow_fastlane_action_sh
@message = 'Some commit message with spaces'
Expand Down Expand Up @@ -110,7 +110,10 @@
end
end

context('point_to_same_commit?(ref1, ref2)') do
describe 'point_to_same_commit?(ref1, ref2)' do
# We cannot test the happy path using a remote because the repo we use for the tests does not have a remote.
let(:remote_name) { nil }

before do
# Spec branching setup:
#
Expand Down Expand Up @@ -145,37 +148,37 @@
end

it 'checks if a tag and a branch point to the same commit' do
same_commit = described_class.point_to_same_commit?('1.0', 'another-branch', remote_name: nil)
same_commit = described_class.point_to_same_commit?('1.0', 'another-branch', remote_name: remote_name)
expect(same_commit).to be false
end

it 'checks if a tag and a branch that had a merge point to the same commit' do
same_commit = described_class.point_to_same_commit?('1.0', 'main', remote_name: nil)
same_commit = described_class.point_to_same_commit?('1.0', 'main', remote_name: remote_name)
expect(same_commit).to be false
end

it 'checks if a tag and a commit hash point to the same commit' do
same_commit = described_class.point_to_same_commit?('1.0', commit_hash(commit_message: 'commit D'), remote_name: nil)
same_commit = described_class.point_to_same_commit?('1.0', commit_hash(commit_message: 'commit D'), remote_name: remote_name)
expect(same_commit).to be false
end

it 'checks if a commit hash and a branch point to the same commit' do
same_commit = described_class.point_to_same_commit?(commit_hash(commit_message: 'commit B'), 'another-branch', remote_name: nil)
same_commit = described_class.point_to_same_commit?(commit_hash(commit_message: 'commit B'), 'another-branch', remote_name: remote_name)
expect(same_commit).to be false
end

it 'checks if commits between the same branch point to the same commit' do
same_commit = described_class.point_to_same_commit?('feature-branch', 'feature-branch', remote_name: nil)
same_commit = described_class.point_to_same_commit?('feature-branch', 'feature-branch', remote_name: remote_name)
expect(same_commit).to be true
end

it 'checks if commits between branches that have no difference point to the same commit' do
same_commit = described_class.point_to_same_commit?('another-branch', 'new-branch', remote_name: nil)
same_commit = described_class.point_to_same_commit?('another-branch', 'new-branch', remote_name: remote_name)
expect(same_commit).to be true
end

it 'raises error for a non-existent base_ref' do
expect { described_class.point_to_same_commit?('non-existent', 'main', remote_name: nil) }.to raise_error(StandardError)
expect { described_class.point_to_same_commit?('non-existent', 'main', remote_name: remote_name) }.to raise_error(StandardError)
end
end

Expand Down

0 comments on commit 36cd7bc

Please sign in to comment.