Files
dsh-infstarapi/tests/release-package.test.mjs
大阔andClaude Opus 5.5 ed5154c042 feat: dsh-geek2api 0.1.0, a Geek2API route for DeepSeek Harness
Derived from dsh-packycode-api 1.1.7 (MIT) and rebuilt for the Geek2API
(sub2api) gateway: multi-endpoint failover, /v1/usage balances with wallet
dedupe, per-key coverage from /v1/models, sub2api failure wording, a Claude
runtime switch (HTTP or local CLI), and Claude/GPT web search backends.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-15 00:50:06 +08:00

37 lines
1.9 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFile, realpath, stat } from 'node:fs/promises'
import { isAbsolute, relative, resolve, sep } from 'node:path'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
const read = (path, encoding = 'utf8') => readFile(new URL(`../${path}`, import.meta.url), encoding)
test('plugin card icon is declared, packaged, and within the host byte limit', async () => {
const manifest = JSON.parse(await read('package.json'))
assert.equal(manifest.icon, './icon-geek2api.webp', 'DSH reads the top-level icon field')
assert.equal(manifest.exports['./package.json'], './package.json', 'DSH must resolve the exported manifest')
const root = await realpath(fileURLToPath(new URL('../', import.meta.url)))
const iconPath = await realpath(resolve(root, manifest.icon))
const local = relative(root, iconPath)
assert.ok(!isAbsolute(local) && local !== '..' && !local.startsWith(`..${sep}`), 'icon must remain inside the package')
assert.ok((await stat(iconPath)).isFile(), 'icon must be a regular file')
assert.ok(manifest.files.includes(manifest.icon.slice(2)), 'publish files must include the icon')
const bytes = await readFile(iconPath)
assert.ok(bytes.length > 0 && bytes.length <= 256 * 1024, 'DSH admits icon files of at most 256 KiB')
assert.equal(bytes.toString('ascii', 0, 4), 'RIFF')
assert.equal(bytes.toString('ascii', 8, 12), 'WEBP')
assert.equal(bytes.readUInt32LE(4) + 8, bytes.length, 'WebP container must be complete')
})
test('release package includes the README mascot', async () => {
const manifest = JSON.parse(await read('package.json'))
const mascot = 'docs/assets/dsh-geek2api-mascot.png'
assert.ok(manifest.files.includes(mascot), 'publish files must include the README mascot')
assert.ok((await read(mascot, null)).length > 0, 'mascot must exist and be nonempty')
for (const path of ['README.md', 'README.en.md']) {
assert.ok((await read(path)).includes(mascot))
}
})