Skip to content

Commit a87568e

Browse files
committed
test: Ignore file access error tests on Windows
1 parent 5dcaf4e commit a87568e

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

src/files/access.test.ts

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,34 @@ export function testAsyncFileAccess(
77
fn: (file: BIDSFileDeno, ...args: any[]) => Promise<any>,
88
...args: any[]
99
) {
10-
Deno.test(name, async (t) => {
11-
await t.step('Dangling symlink', async () => {
12-
const file = new BIDSFileDeno('tests/data', '/broken-symlink')
13-
try {
14-
await fn(file, ...args)
15-
assert(false, 'Expected error')
16-
} catch (e: any) {
17-
assertObjectMatch(e, {
18-
code: 'FILE_READ',
19-
location: '/broken-symlink',
20-
})
21-
assertArrayIncludes(['NotFound', 'FilesystemLoop'], [e.subCode])
22-
}
23-
})
24-
await t.step('Insufficient permissions', async () => {
25-
const tmpfile = await Deno.makeTempFile()
26-
await Deno.chmod(tmpfile, 0o000)
27-
const file = new BIDSFileDeno('', tmpfile)
28-
try {
29-
await fn(file, ...args)
30-
assert(false, 'Expected error')
31-
} catch (e: any) {
32-
assertObjectMatch(e, { code: 'FILE_READ', subCode: 'PermissionDenied' })
33-
}
34-
})
10+
Deno.test({
11+
name,
12+
ignore: Deno.build.os === 'windows',
13+
async fn(t) {
14+
await t.step('Dangling symlink', async () => {
15+
const file = new BIDSFileDeno('tests/data', '/broken-symlink')
16+
try {
17+
await fn(file, ...args)
18+
assert(false, 'Expected error')
19+
} catch (e: any) {
20+
assertObjectMatch(e, {
21+
code: 'FILE_READ',
22+
location: '/broken-symlink',
23+
})
24+
assertArrayIncludes(['NotFound', 'FilesystemLoop'], [e.subCode])
25+
}
26+
})
27+
await t.step('Insufficient permissions', async () => {
28+
const tmpfile = await Deno.makeTempFile()
29+
await Deno.chmod(tmpfile, 0o000)
30+
const file = new BIDSFileDeno('', tmpfile)
31+
try {
32+
await fn(file, ...args)
33+
assert(false, 'Expected error')
34+
} catch (e: any) {
35+
assertObjectMatch(e, { code: 'FILE_READ', subCode: 'PermissionDenied' })
36+
}
37+
})
38+
},
3539
})
3640
}

0 commit comments

Comments
 (0)