chore: generate

This commit is contained in:
opencode-agent[bot]
2026-05-13 15:06:14 +00:00
parent 02b8b0ff93
commit 50dccac915
2 changed files with 92 additions and 85 deletions
+86 -80
View File
@@ -150,26 +150,28 @@ function ready(directory: string) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
describeWatcher("FileWatcher", () => { describeWatcher("FileWatcher", () => {
it.instance("publishes root create, update, and delete events", () => it.instance(
Effect.gen(function* () { "publishes root create, update, and delete events",
const test = yield* TestInstance () =>
const fs = yield* AppFileSystem.Service Effect.gen(function* () {
const file = path.join(test.directory, "watch.txt") const test = yield* TestInstance
const cases = [ const fs = yield* AppFileSystem.Service
{ event: "add" as const, trigger: fs.writeFileString(file, "a") }, const file = path.join(test.directory, "watch.txt")
{ event: "change" as const, trigger: fs.writeFileString(file, "b") }, const cases = [
{ event: "unlink" as const, trigger: fs.remove(file) }, { event: "add" as const, trigger: fs.writeFileString(file, "a") },
] { event: "change" as const, trigger: fs.writeFileString(file, "b") },
{ event: "unlink" as const, trigger: fs.remove(file) },
]
yield* withWatcher( yield* withWatcher(
test.directory, test.directory,
Effect.forEach(cases, ({ event, trigger }) => Effect.forEach(cases, ({ event, trigger }) =>
nextUpdate(test.directory, (evt) => evt.file === file && evt.event === event, trigger).pipe( nextUpdate(test.directory, (evt) => evt.file === file && evt.event === event, trigger).pipe(
Effect.tap((evt) => Effect.sync(() => expect(evt).toEqual({ file, event }))), Effect.tap((evt) => Effect.sync(() => expect(evt).toEqual({ file, event }))),
),
), ),
), )
) }),
}),
{ git: true }, { git: true },
) )
@@ -181,77 +183,81 @@ describeWatcher("FileWatcher", () => {
yield* withWatcher( yield* withWatcher(
test.directory, test.directory,
nextUpdate( nextUpdate(test.directory, (e) => e.file === file && e.event === "add", fs.writeFileString(file, "plain")).pipe(
test.directory, Effect.tap((evt) => Effect.sync(() => expect(evt).toEqual({ file, event: "add" }))),
(e) => e.file === file && e.event === "add",
fs.writeFileString(file, "plain"),
).pipe(Effect.tap((evt) => Effect.sync(() => expect(evt).toEqual({ file, event: "add" })))),
)
}),
)
it.instance("cleanup stops publishing events", () =>
Effect.gen(function* () {
const test = yield* TestInstance
const fs = yield* AppFileSystem.Service
const file = path.join(test.directory, "after-dispose.txt")
// Start and immediately stop the watcher (withWatcher disposes on exit).
yield* withWatcher(test.directory, Effect.void)
// Now write a file - no watcher should be listening.
yield* noUpdate(test.directory, (e) => e.file === file, fs.writeFileString(file, "gone")).pipe(
provideInstance(test.directory),
)
}),
{ git: true },
)
it.instance("ignores .git/index changes", () =>
Effect.gen(function* () {
const test = yield* TestInstance
const fs = yield* AppFileSystem.Service
const git = yield* Git.Service
const gitIndex = path.join(test.directory, ".git", "index")
const edit = path.join(test.directory, "tracked.txt")
yield* withWatcher(
test.directory,
noUpdate(
test.directory,
(e) => e.file === gitIndex,
fs.writeFileString(edit, "a").pipe(Effect.andThen(git.run(["add", "."], { cwd: test.directory }))),
), ),
) )
}), }),
)
it.instance(
"cleanup stops publishing events",
() =>
Effect.gen(function* () {
const test = yield* TestInstance
const fs = yield* AppFileSystem.Service
const file = path.join(test.directory, "after-dispose.txt")
// Start and immediately stop the watcher (withWatcher disposes on exit).
yield* withWatcher(test.directory, Effect.void)
// Now write a file - no watcher should be listening.
yield* noUpdate(test.directory, (e) => e.file === file, fs.writeFileString(file, "gone")).pipe(
provideInstance(test.directory),
)
}),
{ git: true }, { git: true },
) )
it.instance("publishes .git/HEAD events", () => it.instance(
Effect.gen(function* () { "ignores .git/index changes",
const test = yield* TestInstance () =>
const fs = yield* AppFileSystem.Service Effect.gen(function* () {
const git = yield* Git.Service const test = yield* TestInstance
const head = path.join(test.directory, ".git", "HEAD") const fs = yield* AppFileSystem.Service
const branch = `watch-${Math.random().toString(36).slice(2)}` const git = yield* Git.Service
yield* git.run(["branch", branch], { cwd: test.directory }) const gitIndex = path.join(test.directory, ".git", "index")
const edit = path.join(test.directory, "tracked.txt")
yield* withWatcher( yield* withWatcher(
test.directory,
nextUpdate(
test.directory, test.directory,
(evt) => evt.file === head && evt.event !== "unlink", noUpdate(
fs.writeFileString(head, `ref: refs/heads/${branch}\n`), test.directory,
).pipe( (e) => e.file === gitIndex,
Effect.tap((evt) => fs.writeFileString(edit, "a").pipe(Effect.andThen(git.run(["add", "."], { cwd: test.directory }))),
Effect.sync(() => {
expect(evt.file).toBe(head)
expect(["add", "change"]).toContain(evt.event)
}),
), ),
), )
) }),
}), { git: true },
)
it.instance(
"publishes .git/HEAD events",
() =>
Effect.gen(function* () {
const test = yield* TestInstance
const fs = yield* AppFileSystem.Service
const git = yield* Git.Service
const head = path.join(test.directory, ".git", "HEAD")
const branch = `watch-${Math.random().toString(36).slice(2)}`
yield* git.run(["branch", branch], { cwd: test.directory })
yield* withWatcher(
test.directory,
nextUpdate(
test.directory,
(evt) => evt.file === head && evt.event !== "unlink",
fs.writeFileString(head, `ref: refs/heads/${branch}\n`),
).pipe(
Effect.tap((evt) =>
Effect.sync(() => {
expect(evt.file).toBe(head)
expect(["add", "change"]).toContain(evt.event)
}),
),
),
)
}),
{ git: true }, { git: true },
) )
}) })
@@ -167,7 +167,11 @@ const trackBrowserOpenFailed = Effect.gen(function* () {
const authenticateScoped = (name: string) => const authenticateScoped = (name: string) =>
Effect.gen(function* () { Effect.gen(function* () {
const mcp = yield* service const mcp = yield* service
yield* mcp.authenticate(name).pipe(Effect.ignore, Effect.catchCause(() => Effect.void), Effect.forkScoped) yield* mcp.authenticate(name).pipe(
Effect.ignore,
Effect.catchCause(() => Effect.void),
Effect.forkScoped,
)
}) })
mcpTest.instance( mcpTest.instance(
@@ -180,10 +184,7 @@ mcpTest.instance(
const event = yield* trackBrowserOpenFailed const event = yield* trackBrowserOpenFailed
yield* authenticateScoped("test-oauth-server") yield* authenticateScoped("test-oauth-server")
const failure = yield* awaitWithTimeout( const failure = yield* awaitWithTimeout(Deferred.await(event), "Timed out waiting for BrowserOpenFailed event")
Deferred.await(event),
"Timed out waiting for BrowserOpenFailed event",
)
expect(failure.mcpName).toBe("test-oauth-server") expect(failure.mcpName).toBe("test-oauth-server")
expect(failure.url).toContain("https://") expect(failure.url).toContain("https://")