skillhub/cli/test/unit/platform/paths.test.ts
D41910 db6308adde fix(web): align namespace slug validation with SlugValidator
The create-namespace dialog validates slugs client-side before sending
the request, and its pattern was still ASCII-only. SlugValidator has
accepted Unicode letters, numbers and symbols since #196, so the form
rejected slugs the server accepts.

Signed-off-by: D41910 <158550716+D41910@users.noreply.github.com>
2026-10-15 01:22:38 +08:00

27 lines
909 B
TypeScript

import { describe, expect, test } from 'bun:test'
import { stat } from 'node:fs/promises'
import { mkdtemp, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { applyCredentialPermissions, userStateDir } from '../../../src/platform/paths'
describe('userStateDir', () => {
test('throws when home is empty string', () => {
expect(() => userStateDir('')).toThrow('Cannot resolve user home directory')
})
})
describe('applyCredentialPermissions', () => {
test('sets 0o600 on unix', async () => {
const tempDir = await mkdtemp(join(tmpdir(), 'skillhub-test-'))
const tempFile = join(tempDir, 'credential.json')
await writeFile(tempFile, '{}')
await applyCredentialPermissions(tempFile)
if (process.platform !== 'win32') {
const stats = await stat(tempFile)
expect(stats.mode & 0o777).toBe(0o600)
}
})
})