Skip to content

Commit 49911ce

Browse files
committed
test: use instance helper in question tool tests
1 parent ed00ae2 commit 49911ce

1 file changed

Lines changed: 40 additions & 45 deletions

File tree

packages/opencode/test/tool/question.test.ts

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { SessionID, MessageID } from "../../src/session/schema"
66
import { Agent } from "../../src/agent/agent"
77
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
88
import { Truncate } from "@/tool/truncate"
9-
import { provideTmpdirInstance } from "../fixture/fixture"
109
import { testEffect } from "../lib/effect"
1110

1211
const ctx = {
@@ -34,56 +33,52 @@ const pending = Effect.fn("QuestionToolTest.pending")(function* (question: Quest
3433
})
3534

3635
describe("tool.question", () => {
37-
it.live("should successfully execute with valid question parameters", () =>
38-
provideTmpdirInstance(() =>
39-
Effect.gen(function* () {
40-
const question = yield* Question.Service
41-
const toolInfo = yield* QuestionTool
42-
const tool = yield* toolInfo.init()
43-
const questions = [
44-
{
45-
question: "What is your favorite color?",
46-
header: "Color",
47-
options: [
48-
{ label: "Red", description: "The color of passion" },
49-
{ label: "Blue", description: "The color of sky" },
50-
],
51-
multiple: false,
52-
},
53-
]
36+
it.instance("should successfully execute with valid question parameters", () =>
37+
Effect.gen(function* () {
38+
const question = yield* Question.Service
39+
const toolInfo = yield* QuestionTool
40+
const tool = yield* toolInfo.init()
41+
const questions = [
42+
{
43+
question: "What is your favorite color?",
44+
header: "Color",
45+
options: [
46+
{ label: "Red", description: "The color of passion" },
47+
{ label: "Blue", description: "The color of sky" },
48+
],
49+
multiple: false,
50+
},
51+
]
5452

55-
const fiber = yield* tool.execute({ questions }, ctx).pipe(Effect.forkScoped)
56-
const item = yield* pending(question)
57-
yield* question.reply({ requestID: item.id, answers: [["Red"]] })
53+
const fiber = yield* tool.execute({ questions }, ctx).pipe(Effect.forkScoped)
54+
const item = yield* pending(question)
55+
yield* question.reply({ requestID: item.id, answers: [["Red"]] })
5856

59-
const result = yield* Fiber.join(fiber)
60-
expect(result.title).toBe("Asked 1 question")
61-
}),
62-
),
57+
const result = yield* Fiber.join(fiber)
58+
expect(result.title).toBe("Asked 1 question")
59+
}),
6360
)
6461

65-
it.live("should now pass with a header longer than 12 but less than 30 chars", () =>
66-
provideTmpdirInstance(() =>
67-
Effect.gen(function* () {
68-
const question = yield* Question.Service
69-
const toolInfo = yield* QuestionTool
70-
const tool = yield* toolInfo.init()
71-
const questions = [
72-
{
73-
question: "What is your favorite animal?",
74-
header: "This Header is Over 12",
75-
options: [{ label: "Dog", description: "Man's best friend" }],
76-
},
77-
]
62+
it.instance("should now pass with a header longer than 12 but less than 30 chars", () =>
63+
Effect.gen(function* () {
64+
const question = yield* Question.Service
65+
const toolInfo = yield* QuestionTool
66+
const tool = yield* toolInfo.init()
67+
const questions = [
68+
{
69+
question: "What is your favorite animal?",
70+
header: "This Header is Over 12",
71+
options: [{ label: "Dog", description: "Man's best friend" }],
72+
},
73+
]
7874

79-
const fiber = yield* tool.execute({ questions }, ctx).pipe(Effect.forkScoped)
80-
const item = yield* pending(question)
81-
yield* question.reply({ requestID: item.id, answers: [["Dog"]] })
75+
const fiber = yield* tool.execute({ questions }, ctx).pipe(Effect.forkScoped)
76+
const item = yield* pending(question)
77+
yield* question.reply({ requestID: item.id, answers: [["Dog"]] })
8278

83-
const result = yield* Fiber.join(fiber)
84-
expect(result.output).toContain(`"What is your favorite animal?"="Dog"`)
85-
}),
86-
),
79+
const result = yield* Fiber.join(fiber)
80+
expect(result.output).toContain(`"What is your favorite animal?"="Dog"`)
81+
}),
8782
)
8883

8984
// intentionally removed the zod validation due to tool call errors, hoping prompting is gonna be good enough

0 commit comments

Comments
 (0)