mirror of
https://github.com/iflytek/skillhub.git
synced 2026-08-28 11:25:00 +00:00
Add 36 test cases covering: - Path traversal and symlink attack prevention in archive extraction - SkillHubClient error handling (401/403/404/network) for all endpoints - Inventory store concurrent writes and stale lock recovery - Config store read/write round-trip - Platform utilities (package-manager, updater, paths) - Output formatting (printResult, humanize) Tests use cross-platform commands (node) instead of shell builtins for CI compatibility across macOS/Linux/Windows.
30 lines
1,005 B
TypeScript
30 lines
1,005 B
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import { detectInstallMode } from '../../../src/platform/package-manager'
|
|
|
|
describe('detectInstallMode', () => {
|
|
test('detects npx from _npx/ in argv', () => {
|
|
const result = detectInstallMode(['/usr/bin/bun', '/tmp/_npx/abc/skillhub'], {})
|
|
expect(result).toBe('npx')
|
|
})
|
|
|
|
test('detects npm-global from npm_config_prefix', () => {
|
|
const result = detectInstallMode(
|
|
['/usr/bin/bun', '/usr/local/lib/node_modules/.bin/skillhub'],
|
|
{ npm_config_prefix: '/usr/local' }
|
|
)
|
|
expect(result).toBe('npm-global')
|
|
})
|
|
|
|
test('detects bun-global from BUN_INSTALL', () => {
|
|
const result = detectInstallMode(
|
|
['/usr/bin/bun', '/home/user/.bun/bin/skillhub'],
|
|
{ BUN_INSTALL: '/home/user/.bun' }
|
|
)
|
|
expect(result).toBe('bun-global')
|
|
})
|
|
|
|
test('returns unknown as fallback', () => {
|
|
const result = detectInstallMode(['/usr/bin/bun', '/random/path/skillhub'], {})
|
|
expect(result).toBe('unknown')
|
|
})
|
|
})
|