From 650680443e3cb339fc81a96e28555cc4352b5281 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 14 Mar 2026 00:14:46 -0500 Subject: [PATCH] fix: remove unused import + add corrupt cache test Address pre-landing review findings: - Remove unused mkdirSync import from gstack-update-check.test.ts - Add Path I test: corrupt cache file falls through to remote fetch Co-Authored-By: Claude Opus 4.6 --- browse/test/gstack-update-check.test.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/browse/test/gstack-update-check.test.ts b/browse/test/gstack-update-check.test.ts index 7856f03d..ac674b3d 100644 --- a/browse/test/gstack-update-check.test.ts +++ b/browse/test/gstack-update-check.test.ts @@ -7,7 +7,7 @@ */ import { describe, test, expect, beforeEach, afterEach } from 'bun:test'; -import { mkdtempSync, writeFileSync, rmSync, existsSync, readFileSync, mkdirSync } from 'fs'; +import { mkdtempSync, writeFileSync, rmSync, existsSync, readFileSync } from 'fs'; import { join } from 'path'; import { tmpdir } from 'os'; @@ -160,6 +160,21 @@ describe('gstack-update-check', () => { expect(cache).toContain('UP_TO_DATE'); }); + // ─── Path I: Corrupt cache file ───────────────────────────── + test('falls through to remote fetch when cache is corrupt', () => { + writeFileSync(join(gstackDir, 'VERSION'), '0.3.3\n'); + writeFileSync(join(stateDir, 'last-update-check'), 'garbage data here'); + // Remote says same version — should end up UP_TO_DATE + writeFileSync(join(gstackDir, 'REMOTE_VERSION'), '0.3.3\n'); + + const { exitCode, stdout } = run(); + expect(exitCode).toBe(0); + expect(stdout).toBe(''); + // Cache should be overwritten with valid content + const cache = readFileSync(join(stateDir, 'last-update-check'), 'utf-8'); + expect(cache).toContain('UP_TO_DATE'); + }); + // ─── State dir creation ───────────────────────────────────── test('creates state dir if it does not exist', () => { const newStateDir = join(stateDir, 'nested', 'dir');