Skip to content

Commit f1fdfca

Browse files
committed
refactor: checkAuthorEmails logs refactored and test changed accordingly
1 parent 5857bf3 commit f1fdfca

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

src/proxy/processors/push-action/checkAuthorEmails.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ const exec = async (req: any, action: Action): Promise<Action> => {
3939
const illegalEmails = uniqueAuthorEmails.filter((email) => !isEmailAllowed(email));
4040

4141
if (illegalEmails.length > 0) {
42-
console.log(`The following commit author e-mails are illegal: ${illegalEmails}`);
43-
4442
step.error = true;
4543
step.log(`The following commit author e-mails are illegal: ${illegalEmails}`);
4644
step.setError(
@@ -51,7 +49,7 @@ const exec = async (req: any, action: Action): Promise<Action> => {
5149
return action;
5250
}
5351

54-
console.log(`The following commit author e-mails are legal: ${uniqueAuthorEmails}`);
52+
step.log(`The following commit author e-mails are legal: ${uniqueAuthorEmails}`);
5553
action.addStep(step);
5654
return action;
5755
};

test/processors/checkAuthorEmails.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
22
import { exec } from '../../src/proxy/processors/push-action/checkAuthorEmails';
3-
import { Action } from '../../src/proxy/actions';
3+
import { Action, Step } from '../../src/proxy/actions';
44
import * as configModule from '../../src/config';
55
import * as validator from 'validator';
66
import { CommitData } from '../../src/proxy/processors/types';
@@ -47,7 +47,7 @@ describe('checkAuthorEmails', () => {
4747
});
4848

4949
// mock console.log to suppress output and verify calls
50-
consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
50+
consoleLogSpy = vi.spyOn(Step.prototype, 'log').mockImplementation(() => {});
5151

5252
// setup mock action
5353
mockAction = {

0 commit comments

Comments
 (0)