Skip to content

Commit 583b8ed

Browse files
committed
test: increase coverage for pre-receive
1 parent 7fdc970 commit 583b8ed

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
exit 99

test/preReceive/preReceive.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,19 @@ describe('Pre-Receive Hook Execution', function () {
120120
expect(action.setAutoApproval.called).to.be.false;
121121
expect(action.setAutoRejection.called).to.be.false;
122122
});
123+
124+
it('should handle unexpected hook status codes', async () => {
125+
const scriptPath = path.resolve(__dirname, 'pre-receive-hooks/always-exit-99.sh');
126+
127+
const result = await exec(req, action, scriptPath);
128+
129+
expect(result.steps).to.have.lengthOf(1);
130+
expect(result.steps[0].error).to.be.true;
131+
expect(result.steps[0].logs.some((log) => log.includes('Unexpected hook status: 99'))).to.be
132+
.true;
133+
expect(result.steps[0].logs.some((log) => log.includes('Unknown pre-receive hook error.'))).to
134+
.be.true;
135+
expect(action.setAutoApproval.called).to.be.false;
136+
expect(action.setAutoRejection.called).to.be.false;
137+
});
123138
});

0 commit comments

Comments
 (0)