34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
/**
|
|
* buildDockhandOverrideFile: the .env.dockhand contents shared by both git-stack
|
|
* deploy paths (local writeFileSync + Hawser stackFiles). A zero-var git stack must
|
|
* still produce a (header-only) file so a compose referencing env_file: .env.dockhand
|
|
* can resolve it (#1336).
|
|
*/
|
|
import { describe, it, expect } from 'bun:test';
|
|
import { buildDockhandOverrideFile } from '../src/lib/server/dockhand-override-file';
|
|
|
|
describe('buildDockhandOverrideFile', () => {
|
|
it('returns a header-only file (no trailing blank line) for ZERO vars', () => {
|
|
const out = buildDockhandOverrideFile({});
|
|
expect(out).toBe(
|
|
'# Auto-generated by Dockhand. Do not edit - changes will be overwritten on next deploy.\n'
|
|
);
|
|
// exactly one trailing newline - no empty value line that could clear a repo var
|
|
expect(out.endsWith('\n')).toBe(true);
|
|
expect(out.endsWith('\n\n')).toBe(false);
|
|
});
|
|
|
|
it('writes KEY=value lines under the header', () => {
|
|
const out = buildDockhandOverrideFile({ A: '1', B: 'two' });
|
|
expect(out).toContain('A=1');
|
|
expect(out).toContain('B=two');
|
|
expect(out.startsWith('# Auto-generated')).toBe(true);
|
|
expect(out.endsWith('\n')).toBe(true);
|
|
});
|
|
|
|
it('keeps values verbatim (including = and spaces)', () => {
|
|
const out = buildDockhandOverrideFile({ URL: 'https://x/y?a=b c' });
|
|
expect(out).toContain('URL=https://x/y?a=b c');
|
|
});
|
|
});
|