ci/woodpecker/push/publish Pipeline was successful
Co-authored-by: ops-deploy-01 <[email protected]>
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { Readable } from 'node:stream';
|
|
import { readCredentialsFromPipedStdin } from './piped-credentials.js';
|
|
|
|
describe('readCredentialsFromPipedStdin — #1394 stdin dual path (real streams)', () => {
|
|
it('reads exactly two lines; email trimmed, password as-is', async () => {
|
|
const r = await readCredentialsFromPipedStdin(
|
|
Readable.from([' [email protected] \n', 'pw with spaces \n']),
|
|
);
|
|
expect(r.email).toBe('[email protected]');
|
|
expect(r.password).toBe('pw with spaces ');
|
|
});
|
|
|
|
it('empty stdin → nulls (the headless-no-credentials shape)', async () => {
|
|
const r = await readCredentialsFromPipedStdin(Readable.from(['']));
|
|
expect(r).toEqual({ email: null, password: null });
|
|
});
|
|
|
|
it('single line only → email set, password null', async () => {
|
|
const r = await readCredentialsFromPipedStdin(Readable.from(['only-email\n']));
|
|
expect(r.email).toBe('only-email');
|
|
expect(r.password).toBeNull();
|
|
});
|
|
|
|
it('stops after two lines even if more follow', async () => {
|
|
const r = await readCredentialsFromPipedStdin(
|
|
Readable.from(['[email protected]\n', 'pw\n', 'extra\n', 'more\n']),
|
|
);
|
|
expect(r).toEqual({ email: '[email protected]', password: 'pw' });
|
|
});
|
|
});
|