Skip to content

Commit b633cbb

Browse files
konardclaude
andcommitted
fix(tests): replace try/catch with Effect.ensuring in auto-pull test
Effect-TS lint rule forbids try/catch in product code. Uses Effect.ensuring to restore env var after test assertion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent df63c5c commit b633cbb

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

packages/lib/tests/usecases/state-repo-auto-pull.test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,21 @@ describe("autoPullState", () => {
244244
yield* _(captureGit(["commit", "-m", "new commit"], pusherDir))
245245
yield* _(captureGit(["push", "origin", "HEAD:refs/heads/main"], pusherDir))
246246

247-
// Disable auto-pull
247+
// Disable auto-pull via env var and restore after
248248
const prevAutoPull = process.env["DOCKER_GIT_STATE_AUTO_PULL"]
249249
process.env["DOCKER_GIT_STATE_AUTO_PULL"] = "false"
250-
try {
251-
yield* _(autoPullState)
252-
} finally {
253-
if (prevAutoPull === undefined) {
254-
delete process.env["DOCKER_GIT_STATE_AUTO_PULL"]
255-
} else {
256-
process.env["DOCKER_GIT_STATE_AUTO_PULL"] = prevAutoPull
257-
}
258-
}
250+
yield* _(
251+
Effect.ensuring(
252+
autoPullState,
253+
Effect.sync(() => {
254+
if (prevAutoPull === undefined) {
255+
delete process.env["DOCKER_GIT_STATE_AUTO_PULL"]
256+
} else {
257+
process.env["DOCKER_GIT_STATE_AUTO_PULL"] = prevAutoPull
258+
}
259+
})
260+
)
261+
)
259262

260263
// HEAD should NOT have changed because auto-pull was disabled
261264
const headAfter = yield* _(captureGit(["rev-parse", "HEAD"], stateRoot))

0 commit comments

Comments
 (0)