Skip to content

Commit 78fc7b8

Browse files
sahrizviclaude
andcommitted
test(workspace): answer the binding lookup in serveSkills, and pin the rebind reason
`syncSkills` resolves the binding on the network every run. `serveSkills` did not answer that lookup, so the mock threw, the lookup was swallowed as "offline", and the new tests passed while running the stale-binding path instead of the bound one. It now confirms the workspace each test binds to. The rebind test also asserts the per-skill reason, so a regression that promised "kept the previous copy" after a rebind would fail. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 44c77ac commit 78fc7b8

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎packages/opencode/test/altimate/workspace/skill-sync.test.ts‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,24 @@ describe("workspace skill sync", () => {
388388
// Serves a workspace whose skills can each misbehave in one way. `detail`
389389
// replaces the detail envelope; `size` overrides the declared file size.
390390
type Spec = { content?: string; size?: number; updated?: string; detail?: unknown; files?: number }
391-
function serveSkills(spec: Record<string, Spec>) {
391+
/** `datamateId` is the workspace the server confirms on the binding
392+
* lookup `syncSkills` makes every run. Answered, not left to fall through:
393+
* an unanswered lookup was swallowed as "offline", so a test passed for a
394+
* degraded reason while claiming to exercise the bound path. */
395+
function serveSkills(spec: Record<string, Spec>, datamateId = 1) {
392396
globalThis.fetch = (async (input: string | URL) => {
393397
const url = String(input)
398+
if (url.includes("/datamate-project-bindings/by-"))
399+
return json({
400+
binding: {
401+
id: 7,
402+
datamate_id: datamateId,
403+
datamate_name: `ws-${datamateId}`,
404+
repo_remote: null,
405+
project_path: project,
406+
},
407+
datamate: { id: datamateId, name: `ws-${datamateId}` },
408+
})
394409
if (url.includes("datamate_id"))
395410
return json({
396411
items: Object.entries(spec).map(([id, s]) => ({
@@ -450,10 +465,12 @@ describe("workspace skill sync", () => {
450465
// The rebind drops workspace 1's snapshot before the pull — so when every
451466
// new skill fails, nothing of the old one is left to have been "kept".
452467
bindTo(2)
453-
serveSkills({ pub9: { content: "short", size: 9999 } })
468+
serveSkills({ pub9: { content: "short", size: 9999 } }, 2)
454469
const result = await syncSkills(project)
455470

456471
expect(result.error).toBe("could not install the workspace skills")
472+
// The per-skill line must not promise a surviving copy either.
473+
expect(result.skipped).toEqual([{ skill: "pub9", reason: "its file size could not be verified" }])
457474
expect(existsSync(skillFile("pub-1", "SKILL.md"))).toBe(false)
458475
})
459476

0 commit comments

Comments
 (0)