Skip to content

Commit 8283c0a

Browse files
Update function info tests for new functionOutputPath parameter
Co-authored-by: Claude Code <claude-code@anthropic.com>
1 parent 53a8872 commit 8283c0a

1 file changed

Lines changed: 65 additions & 4 deletions

File tree

packages/app/src/cli/services/function/info.test.ts

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,52 @@ describe('functionInfo', () => {
4949
expect(parsed).toHaveProperty('apiVersion')
5050
})
5151

52+
test('uses build.path from config for wasmPath when present', async () => {
53+
// Given
54+
const funcWithBuildPath = await testFunctionExtension({
55+
dir: '/path/to/function',
56+
config: {
57+
name: 'My Function',
58+
type: 'function',
59+
handle: 'my-function',
60+
api_version: '2024-01',
61+
configuration_ui: false,
62+
build: {
63+
path: 'custom/output.wasm',
64+
wasm_opt: false,
65+
},
66+
},
67+
})
68+
const options = {
69+
format: 'json' as const,
70+
functionRunnerPath: '/path/to/runner',
71+
schemaPath: '/path/to/schema.graphql',
72+
}
73+
74+
// When
75+
const result = functionInfo(funcWithBuildPath, options)
76+
77+
// Then
78+
const parsed = JSON.parse(result as string)
79+
expect(parsed.wasmPath).toBe('/path/to/function/custom/output.wasm')
80+
})
81+
82+
test('falls back to outputRelativePath when build.path is not set', async () => {
83+
// Given
84+
const options = {
85+
format: 'json' as const,
86+
functionRunnerPath: '/path/to/runner',
87+
schemaPath: '/path/to/schema.graphql',
88+
}
89+
90+
// When
91+
const result = functionInfo(ourFunction, options)
92+
93+
// Then
94+
const parsed = JSON.parse(result as string)
95+
expect(parsed.wasmPath).toBe(ourFunction.outputPath)
96+
})
97+
5298
test('returns AlertCustomSection array when format is text', async () => {
5399
// Given
54100
const options = {
@@ -174,7 +220,15 @@ describe('functionInfo', () => {
174220
}
175221

176222
// When
177-
const result = formatAsJson(testFunc, config, targeting, '/path/to/runner', '/path/to/schema.graphql')
223+
const functionOutputPath = '/path/to/function/output.wasm'
224+
const result = formatAsJson(
225+
testFunc,
226+
config,
227+
targeting,
228+
'/path/to/runner',
229+
functionOutputPath,
230+
'/path/to/schema.graphql',
231+
)
178232

179233
// Then
180234
const parsed = JSON.parse(result)
@@ -189,7 +243,7 @@ describe('functionInfo', () => {
189243
},
190244
},
191245
schemaPath: '/path/to/schema.graphql',
192-
wasmPath: testFunc.outputPath,
246+
wasmPath: functionOutputPath,
193247
functionRunnerPath: '/path/to/runner',
194248
})
195249
})
@@ -209,7 +263,7 @@ describe('functionInfo', () => {
209263
const targeting = {}
210264

211265
// When
212-
const result = formatAsJson(testFunc, config, targeting, '/path/to/runner')
266+
const result = formatAsJson(testFunc, config, targeting, '/path/to/runner', 'path/to/function.wasm', undefined)
213267

214268
// Then
215269
const parsed = JSON.parse(result)
@@ -362,7 +416,14 @@ describe('functionInfo', () => {
362416
}
363417

364418
// When
365-
const result = buildTextFormatSections(testFunc, config, targeting, '/path/to/runner', '/path/to/schema.graphql')
419+
const result = buildTextFormatSections(
420+
testFunc,
421+
config,
422+
targeting,
423+
'/path/to/runner',
424+
'/path/to/function/output.wasm',
425+
'/path/to/schema.graphql',
426+
)
366427

367428
// Then
368429
// configuration, targeting, build, function runner

0 commit comments

Comments
 (0)