2016-12-09 05:22:20 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Gitlab::Checks::ForcePush do
|
2017-01-24 18:42:12 -05:00
|
|
|
let(:project) { create(:project, :repository) }
|
2018-01-31 14:25:38 -05:00
|
|
|
let(:repository) { project.repository.raw }
|
2016-12-09 05:22:20 -05:00
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
context "exit code checking", :skip_gitaly_mock do
|
2016-12-09 05:22:20 -05:00
|
|
|
it "does not raise a runtime error if the `popen` call to git returns a zero exit code" do
|
2018-01-31 14:25:38 -05:00
|
|
|
allow(repository).to receive(:popen).and_return(['normal output', 0])
|
2016-12-09 05:22:20 -05:00
|
|
|
|
2017-04-25 08:28:55 -04:00
|
|
|
expect { described_class.force_push?(project, 'oldrev', 'newrev') }.not_to raise_error
|
2016-12-09 05:22:20 -05:00
|
|
|
end
|
|
|
|
|
2018-01-31 14:25:38 -05:00
|
|
|
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])
|
2016-12-09 05:22:20 -05:00
|
|
|
|
2018-01-31 14:25:38 -05:00
|
|
|
expect { described_class.force_push?(project, 'oldrev', 'newrev') }
|
|
|
|
.to raise_error(Gitlab::Git::Repository::GitError)
|
2016-12-09 05:22:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|