ReviewOS

also looking at this

stacks/ts-cloud

test(fleet): prove the database and hostname halves of a transfer on real machines

#184
Merged glennmichael123 wants to merge test/move-database-and-rename-e2e into main
4 files +363 -3
packages/ts-cloud/src/operations/server-rename.test.tsmodified+12-1
Changes to packages/ts-cloud/src/operations/server-rename.test.ts
@@ -149,6 +149,17 @@ describe('buildSetHostnameScript', () => {
149149 it('replaces the existing 127.0.1.1 line rather than appending a second', () => {
150150 const script = buildSetHostnameScript('hq-production-server')
151151 expect(script).toContain('s/^127\\.0\\.1\\.1.*/127.0.1.1\\thq-production-server/')
152 expect(script).toContain('if grep -q "127.0.1.1" /etc/hosts; then')
152 expect(script).toContain('if grep -q "^127.0.1.1" /etc/hosts; then')
153 })
154
155 /**
156 * `sed -i` renames a temp file over the target, which fails outright when
157 * /etc/hosts is a bind mount — every container — or is hard-linked. Writing
158 * the content back in place keeps the inode and works either way.
159 */
160 it('rewrites /etc/hosts in place rather than renaming over it', () => {
161 const script = buildSetHostnameScript('hq-production-server')
162 expect(script).not.toContain('sed -i')
163 expect(script).toContain('> /etc/hosts')
153164 })
154165})