Skip to content

Commit d2dc9a9

Browse files
committed
test: update chain test to work with preReceive
1 parent b6953fe commit d2dc9a9

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/chain.test.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const mockPushProcessors = {
2424
checkIfWaitingAuth: sinon.stub(),
2525
pullRemote: sinon.stub(),
2626
writePack: sinon.stub(),
27+
preReceive: sinon.stub(),
2728
getDiff: sinon.stub(),
2829
clearBareClone: sinon.stub(),
2930
scanDiff: sinon.stub(),
@@ -38,6 +39,7 @@ mockPushProcessors.checkUserPushPermission.displayName = 'checkUserPushPermissio
3839
mockPushProcessors.checkIfWaitingAuth.displayName = 'checkIfWaitingAuth';
3940
mockPushProcessors.pullRemote.displayName = 'pullRemote';
4041
mockPushProcessors.writePack.displayName = 'writePack';
42+
mockPushProcessors.preReceive.displayName = 'preReceive';
4143
mockPushProcessors.getDiff.displayName = 'getDiff';
4244
mockPushProcessors.clearBareClone.displayName = 'clearBareClone';
4345
mockPushProcessors.scanDiff.displayName = 'scanDiff';
@@ -63,7 +65,7 @@ describe('proxy chain', function () {
6365
// Re-require the chain module after stubbing processors
6466
chain = require('../src/proxy/chain');
6567

66-
chain.chainPluginLoader = new PluginLoader([])
68+
chain.chainPluginLoader = new PluginLoader([]);
6769
});
6870

6971
afterEach(() => {
@@ -108,7 +110,11 @@ describe('proxy chain', function () {
108110
mockPushProcessors.checkUserPushPermission.resolves(continuingAction);
109111

110112
// this stops the chain from further execution
111-
mockPushProcessors.checkIfWaitingAuth.resolves({ type: 'push', continue: () => false, allowPush: false });
113+
mockPushProcessors.checkIfWaitingAuth.resolves({
114+
type: 'push',
115+
continue: () => false,
116+
allowPush: false,
117+
});
112118
const result = await chain.executeChain(req);
113119

114120
expect(mockPreProcessors.parseAction.called).to.be.true;
@@ -136,7 +142,11 @@ describe('proxy chain', function () {
136142
mockPushProcessors.checkAuthorEmails.resolves(continuingAction);
137143
mockPushProcessors.checkUserPushPermission.resolves(continuingAction);
138144
// this stops the chain from further execution
139-
mockPushProcessors.checkIfWaitingAuth.resolves({ type: 'push', continue: () => true, allowPush: true });
145+
mockPushProcessors.checkIfWaitingAuth.resolves({
146+
type: 'push',
147+
continue: () => true,
148+
allowPush: true,
149+
});
140150
const result = await chain.executeChain(req);
141151

142152
expect(mockPreProcessors.parseAction.called).to.be.true;
@@ -166,6 +176,7 @@ describe('proxy chain', function () {
166176
mockPushProcessors.checkIfWaitingAuth.resolves(continuingAction);
167177
mockPushProcessors.pullRemote.resolves(continuingAction);
168178
mockPushProcessors.writePack.resolves(continuingAction);
179+
mockPushProcessors.preReceive.resolves(continuingAction);
169180
mockPushProcessors.getDiff.resolves(continuingAction);
170181
mockPushProcessors.clearBareClone.resolves(continuingAction);
171182
mockPushProcessors.scanDiff.resolves(continuingAction);
@@ -182,6 +193,7 @@ describe('proxy chain', function () {
182193
expect(mockPushProcessors.checkIfWaitingAuth.called).to.be.true;
183194
expect(mockPushProcessors.pullRemote.called).to.be.true;
184195
expect(mockPushProcessors.writePack.called).to.be.true;
196+
expect(mockPushProcessors.preReceive.called).to.be.true;
185197
expect(mockPushProcessors.getDiff.called).to.be.true;
186198
expect(mockPushProcessors.clearBareClone.called).to.be.true;
187199
expect(mockPushProcessors.scanDiff.called).to.be.true;
@@ -232,5 +244,5 @@ describe('proxy chain', function () {
232244
expect(mockPushProcessors.checkRepoInAuthorisedList.called).to.be.false;
233245
expect(mockPushProcessors.parsePush.called).to.be.false;
234246
expect(result).to.deep.equal(action);
235-
})
247+
});
236248
});

0 commit comments

Comments
 (0)