| 1 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; |
| 2 | import { tmpdir } |
| 3 | import { delimiter, join |
| 4 | import type { ConfigService |
| 5 | |
| 6 | import { mailConfigured, sendmailPath |
| 7 | |
| 8 | const config = ( |
| 9 | ({ get: ( |
| 10 | |
| 11 | describe('sendmail fallback', () |
| 12 | const name = |
| 13 | let dir: |
| 14 | beforeAll(() => |
| 15 | dir = mkdtempSync( |
| 16 | writeFileSync(join(dir |
| 17 | }); |
| 18 | afterAll(() => |
| 19 | |
| 20 | it('finds sendmail on PATH', |
| 21 | expect(sendmailPath(config |
| 22 | }); |
| 23 | |
| 24 | it.skipIf(process |
| 25 | 'skips non-executable candidates on PATH', |
| 26 | () => { |
| 27 | const firstDir = |
| 28 | mkdirSync(firstDir); |
| 29 | writeFileSync(join(firstDir |
| 30 | |
| 31 | expect( |
| 32 | sendmailPath(config({}) |
| 33 | ).toBe(join( |
| 34 | }, |
| 35 | ); |
| 36 | |
| 37 | it('skips directories on PATH', |
| 38 | const firstDir = |
| 39 | mkdirSync(join(firstDir |
| 40 | |
| 41 | expect( |
| 42 | sendmailPath(config({}) |
| 43 | ).toBe(join( |
| 44 | }); |
| 45 | |
| 46 | it('prefers SENDMAIL_PATH', |
| 47 | expect( |
| 48 | sendmailPath(config({ |
| 49 | ).toBe('/opt/bin/msmtp' |
| 50 | }); |
| 51 | |
| 52 | it('treats empty relay and SMTP settings as unset', |
| 53 | expect( |
| 54 | mailConfigured(config({ |
| 55 | ).toBe(true); |
| 56 | }); |
| 57 | }); |