Skip to content

Commit e5de73a

Browse files
committed
Test for CommandError
1 parent a2fbfd6 commit e5de73a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

spec/unit/entitlements/util/gitrepo_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
expect(subject).to receive(:git).with(directory, ["commit", "-m", "My commit message"])
4040
expect(subject.commit(directory, "My commit message")).to be nil
4141
end
42+
43+
it "skips the commit if it receives a command error" do
44+
allow(subject).to receive(:validate_git_repository!)
45+
expect(subject).to receive(:git).with(directory, ["commit", "-m", "My commit message"]).and_raise(Entitlements::Util::GitRepo::CommandError)
46+
expect(logger).to receive(:info).with("No changes to git repository")
47+
expect(subject.commit(directory, "My commit message")).to be nil
48+
end
4249
end
4350

4451
describe "#configure" do

0 commit comments

Comments
 (0)