Skip to content

Commit b3092ff

Browse files
committed
fix: remove unnecessary timeout logic test
1 parent 378306a commit b3092ff

File tree

2 files changed

+1
-50
lines changed

2 files changed

+1
-50
lines changed

test/refresh-pdps.test.js

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jest.mock('dotenv', () => ({
3131

3232
jest.mock('commander', () => {
3333
const mockProgram = {
34+
requiredOption: jest.fn().mockReturnThis(),
3435
option: jest.fn().mockReturnThis(),
3536
parse: jest.fn().mockReturnThis(),
3637
opts: jest.fn().mockReturnValue({ keys: 'en,fr' })
@@ -137,51 +138,4 @@ describe('Refresh PDP Tool Tests', () => {
137138
await expect(mainModule.flushStoreState('en')).rejects.toThrow('Delete Error');
138139
});
139140
});
140-
141-
describe('main function', () => {
142-
beforeEach(() => {
143-
mainModule = require('../tools/refresh-pdps');
144-
mockOpenWhiskInstance.rules.disable.mockResolvedValue({});
145-
mockOpenWhiskInstance.rules.enable.mockResolvedValue({});
146-
mockOpenWhiskInstance.actions.invoke
147-
.mockResolvedValueOnce({ value: 'false' })
148-
.mockResolvedValueOnce({})
149-
.mockResolvedValueOnce({})
150-
.mockResolvedValueOnce({ value: 'true' });
151-
152-
jest.useFakeTimers();
153-
});
154-
155-
afterEach(() => {
156-
jest.useRealTimers();
157-
});
158-
159-
it('should successfully complete the state management cycle', async () => {
160-
const mainPromise = mainModule.main();
161-
jest.runAllTimers();
162-
await mainPromise;
163-
164-
expect(mockOpenWhiskInstance.rules.disable).toHaveBeenCalledWith({
165-
name: 'poll_every_minute'
166-
});
167-
expect(mockOpenWhiskInstance.rules.enable).toHaveBeenCalledWith({
168-
name: 'poll_every_minute'
169-
});
170-
expect(process.exit).toHaveBeenCalledWith(0);
171-
});
172-
173-
it('should timeout if running state never becomes true', async () => {
174-
mockOpenWhiskInstance.actions.invoke.mockResolvedValue({ value: 'false' });
175-
176-
const timeout = 1500; // to simulate in the test env
177-
const mainPromise = mainModule.main(timeout);
178-
jest.advanceTimersByTime(1500);
179-
await mainPromise;
180-
181-
expect(console.error).toHaveBeenCalledWith(
182-
'Timeout: running state did not become true within 30 minutes.'
183-
);
184-
expect(process.exit).toHaveBeenCalledWith(1);
185-
});
186-
});
187141
});

tools/refresh-pdps.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ async function flushStoreState(locale) {
6969
}
7070

7171
async function main(timeout = 20 * 60 * 1000) {
72-
73-
74-
7572
try {
7673
// Disable the rule
7774
await ow.rules.disable({ name: AIO_POLLER_RULE_NAME });

0 commit comments

Comments
 (0)