debian-mirror-gitlab/spec/lib/gitlab/checks/force_push_spec.rb

22 lines
797 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Gitlab::Checks::ForcePush do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2018-03-17 18:26:18 +05:30
let(:repository) { project.repository.raw }
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
context "exit code checking", :skip_gitaly_mock do
2017-08-17 22:00:37 +05:30
it "does not raise a runtime error if the `popen` call to git returns a zero exit code" do
2018-03-17 18:26:18 +05:30
allow(repository).to receive(:popen).and_return(['normal output', 0])
2017-08-17 22:00:37 +05:30
expect { described_class.force_push?(project, 'oldrev', 'newrev') }.not_to raise_error
end
2018-03-17 18:26:18 +05:30
it "raises a GitError error if the `popen` call to git returns a non-zero exit code" do
allow(repository).to receive(:popen).and_return(['error', 1])
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
expect { described_class.force_push?(project, 'oldrev', 'newrev') }
.to raise_error(Gitlab::Git::Repository::GitError)
2017-08-17 22:00:37 +05:30
end
end
end