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) }
|
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
|
2017-09-12 17:52:43 -04:00
|
|
|
allow_any_instance_of(Gitlab::Git::RevList).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
|
|
|
|
|
|
|
|
it "raises a runtime error if the `popen` call to git returns a non-zero exit code" do
|
2017-09-12 17:52:43 -04:00
|
|
|
allow_any_instance_of(Gitlab::Git::RevList).to receive(:popen).and_return(['error', 1])
|
2016-12-09 05:22:20 -05:00
|
|
|
|
2017-04-25 08:28:55 -04:00
|
|
|
expect { described_class.force_push?(project, 'oldrev', 'newrev') }.to raise_error(RuntimeError)
|
2016-12-09 05:22:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|