Skip to content

Commit d588741

Browse files
committed
test(validator): fix cross-platform path handling
- Use Helpers.joinPath for cross-platform path creation - Convert inline objects to multi-line format
1 parent 7c93d2a commit d588741

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

tests/utils/validator.test.ts

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,46 @@ import Helpers from '@tests/helpers/index.ts'
33
import * as Utils from '@app/utils/index.ts'
44

55
Deno.test('Utils.Validator.filterEnvironment - allow list only', () => {
6-
const env = { NODE_ENV: 'test', PATH: '/bin', HOME: '/root', SECRET: 'value' }
6+
const env = {
7+
NODE_ENV: 'test',
8+
PATH: '/bin',
9+
HOME: '/root',
10+
SECRET: 'value'
11+
}
712
const result = Utils.Validator.filterEnvironment(env, ['NODE_ENV', 'PATH'], [])
8-
assertEquals(result, { NODE_ENV: 'test', PATH: '/bin' })
13+
const expected = {
14+
NODE_ENV: 'test',
15+
PATH: '/bin'
16+
}
17+
assertEquals(result, expected)
918
})
1019

1120
Deno.test('Utils.Validator.filterEnvironment - deny list blocks', () => {
12-
const env = { SAFE: 'yes', SECRET: 'no', SSH_KEY: 'private' }
21+
const env = {
22+
SAFE: 'yes',
23+
SECRET: 'no',
24+
SSH_KEY: 'private'
25+
}
1326
const result = Utils.Validator.filterEnvironment(env, [], ['SECRET', 'SSH_*'])
14-
assertEquals(result, { SAFE: 'yes' })
27+
const expected = { SAFE: 'yes' }
28+
assertEquals(result, expected)
1529
})
1630

1731
Deno.test('Utils.Validator.filterEnvironment - deny overrides allow', () => {
1832
const env = { BOTH: 'value' }
1933
const result = Utils.Validator.filterEnvironment(env, ['BOTH'], ['BOTH'])
20-
assertEquals(result, {})
34+
const expected = {}
35+
assertEquals(result, expected)
2136
})
2237

2338
Deno.test('Utils.Validator.filterEnvironment - undefined values excluded', () => {
24-
const env: Record<string, string | undefined> = { DEFINED: 'value', UNDEFINED: undefined }
39+
const env: Record<string, string | undefined> = {
40+
DEFINED: 'value',
41+
UNDEFINED: undefined
42+
}
2543
const result = Utils.Validator.filterEnvironment(env, ['DEFINED', 'UNDEFINED'], [])
26-
assertEquals(result, { DEFINED: 'value' })
44+
const expected = { DEFINED: 'value' }
45+
assertEquals(result, expected)
2746
})
2847

2948
Deno.test('Utils.Validator.hasPathTraversal - detects traversal patterns', () => {
@@ -112,7 +131,7 @@ Deno.test('Utils.Validator.validateCommand - wildcard pattern', () => {
112131

113132
Deno.test('Utils.Validator.validateWorkspace - allowed workspace', async () => {
114133
const workspaceBase = await Helpers.workspace('test1')
115-
const projectPath = `${workspaceBase}/project`
134+
const projectPath = Helpers.joinPath(workspaceBase, 'project')
116135
await Deno.mkdir(projectPath, { recursive: true })
117136
const result = Utils.Validator.validateWorkspace(projectPath, [workspaceBase])
118137
assert(result.valid)
@@ -126,7 +145,7 @@ Deno.test('Utils.Validator.validateWorkspace - empty workspaces allows any', asy
126145

127146
Deno.test('Utils.Validator.validateWorkspace - nested path allowed', async () => {
128147
const workspaceBase = await Helpers.workspace('test2')
129-
const nestedPath = `${workspaceBase}/a/b/c`
148+
const nestedPath = Helpers.joinPath(workspaceBase, 'a', 'b', 'c')
130149
await Deno.mkdir(nestedPath, { recursive: true })
131150
const result = Utils.Validator.validateWorkspace(nestedPath, [workspaceBase])
132151
assert(result.valid)

0 commit comments

Comments
 (0)