Skip to content

Commit 852dfef

Browse files
committed
chore: add tests
1 parent 4c08b71 commit 852dfef

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

__tests__/main.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,19 @@ describe('Gigalixir Deploy Action', () => {
426426
)
427427
}
428428

429+
// Mock exec to handle git rev-parse for SHA resolution
430+
function mockExecWithRevParse(sha: string): void {
431+
mockedExec.exec.mockImplementation(
432+
async (_cmd: string, args?: string[], options?: Record<string, unknown>) => {
433+
if (args && args[0] === 'rev-parse' && options?.listeners) {
434+
const listeners = options.listeners as { stdout?: (data: Buffer) => void }
435+
listeners.stdout?.(Buffer.from(sha))
436+
}
437+
return 0
438+
}
439+
)
440+
}
441+
429442
beforeEach(() => {
430443
jest.useFakeTimers({ advanceTimers: true })
431444
})
@@ -488,6 +501,7 @@ describe('Gigalixir Deploy Action', () => {
488501
}
489502
return inputs[name] || ''
490503
})
504+
mockExecWithRevParse('abc123')
491505

492506
// First poll: old pods still running, new pod starting
493507
// Second poll: all new pods healthy
@@ -559,6 +573,7 @@ describe('Gigalixir Deploy Action', () => {
559573
}
560574
return inputs[name] || ''
561575
})
576+
mockExecWithRevParse('abc123')
562577

563578
// All polls return unhealthy pods
564579
mockHttpsResponses([
@@ -607,6 +622,7 @@ describe('Gigalixir Deploy Action', () => {
607622
}
608623
return inputs[name] || ''
609624
})
625+
mockExecWithRevParse('abc123')
610626

611627
// First poll: API error, second poll: success
612628
mockHttpsResponses([

0 commit comments

Comments
 (0)