Skip to content

Commit f308bab

Browse files
authored
fix(tests): update path handling and Python binary detection for Windows compatibility (#13367)
1 parent 5bffeee commit f308bab

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

packages/serverless/test/unit/lib/plugins/aws/bedrock-agentcore/dev/code-mode.test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
import path from 'path'
34
import {
45
jest,
56
describe,
@@ -10,6 +11,8 @@ import {
1011
} from '@jest/globals'
1112
import EventEmitter from 'events'
1213

14+
const isWin = process.platform === 'win32'
15+
1316
const mockSpawn = jest.fn()
1417
const mockExecP = jest.fn()
1518

@@ -97,8 +100,8 @@ describe('AgentCoreCodeMode', () => {
97100
await mode.start(mockCredentials)
98101

99102
expect(mockSpawn).toHaveBeenCalledWith(
100-
'python3.13',
101-
[expect.stringContaining('agents/main.py')],
103+
isWin ? 'python.exe' : 'python3.13',
104+
[expect.stringContaining(`agents${path.sep}main.py`)],
102105
expect.objectContaining({
103106
cwd: '/home/user/my-agent',
104107
env: expect.objectContaining({
@@ -123,7 +126,7 @@ describe('AgentCoreCodeMode', () => {
123126
await mode.start(mockCredentials)
124127

125128
expect(mockSpawn).toHaveBeenCalledWith(
126-
'python3.13',
129+
isWin ? 'python.exe' : 'python3.13',
127130
expect.any(Array),
128131
expect.any(Object),
129132
)
@@ -137,7 +140,7 @@ describe('AgentCoreCodeMode', () => {
137140
await mode.start(mockCredentials)
138141

139142
expect(mockSpawn).toHaveBeenCalledWith(
140-
'python3.12',
143+
isWin ? 'python.exe' : 'python3.12',
141144
expect.any(Array),
142145
expect.any(Object),
143146
)
@@ -151,7 +154,7 @@ describe('AgentCoreCodeMode', () => {
151154
await mode.start(mockCredentials)
152155

153156
expect(mockSpawn).toHaveBeenCalledWith(
154-
'python3.12',
157+
isWin ? 'python.exe' : 'python3.12',
155158
expect.any(Array),
156159
expect.any(Object),
157160
)

packages/serverless/test/unit/lib/plugins/aws/bedrock-agentcore/docker/builder.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
import path from 'path'
34
import { jest } from '@jest/globals'
45

56
// Mock @serverless/util before importing the module
@@ -241,7 +242,7 @@ describe('DockerBuilder', () => {
241242
expect(mockDockerClient.buildImage).toHaveBeenCalledWith(
242243
expect.objectContaining({
243244
imageUri: 'my-image:latest',
244-
containerPath: '/path/to/service',
245+
containerPath: path.resolve('/path/to/service', '.'),
245246
platform: 'linux/arm64',
246247
}),
247248
)

0 commit comments

Comments
 (0)