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
|
|
|
|
|
|
|
context "exit code checking" do
|
|
|
|
it "does not raise a runtime error if the `popen` call to git returns a zero exit code" do
|
|
|
|
allow(Gitlab::Popen).to receive(:popen).and_return(['normal output', 0])
|
|
|
|
|
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
|
|
|
|
allow(Gitlab::Popen).to receive(:popen).and_return(['error', 1])
|
|
|
|
|
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
|