MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / fakeManifest

Function fakeManifest

apps/kimi-code/test/native/native-assets.test.ts:21–63  ·  view source on GitHub ↗
(files: Record<string, string>)

Source from the content-addressed store, hash-verified

19}
20
21function fakeManifest(files: Record<string, string>): {
22 manifest: NativeAssetManifest;
23 source: NativeAssetSource;
24} {
25 const assetEntries = Object.entries(files).map(([relativePath, content]) => {
26 const assetKey = `native/test-target/${relativePath}`;
27 return {
28 assetKey,
29 relativePath,
30 sha256: sha256(content),
31 };
32 });
33 const manifest: NativeAssetManifest = {
34 version: NATIVE_ASSET_MANIFEST_VERSION,
35 target: 'test-target',
36 packages: [
37 {
38 name: 'fake-native',
39 root: 'node_modules/fake-native',
40 files: assetEntries,
41 },
42 ],
43 };
44 const manifestKey = 'native/test-target/manifest.json';
45 const assets = new Map<string, Buffer>([
46 [manifestKey, Buffer.from(JSON.stringify(manifest))],
47 ...Object.entries(files).map(([relativePath, content]) => [
48 `native/test-target/${relativePath}`,
49 Buffer.from(content),
50 ] as const),
51 ]);
52 return {
53 manifest,
54 source: {
55 getAssetKeys: () => [...assets.keys()],
56 getRawAsset: (assetKey) => {
57 const asset = assets.get(assetKey);
58 if (asset === undefined) throw new Error(`missing test asset: ${assetKey}`);
59 return asset;
60 },
61 },
62 };
63}
64
65describe('native assets', () => {
66 it('uses KIMI_CODE_CACHE_DIR as the native cache base when present', () => {

Callers 1

Calls 3

keysMethod · 0.80
sha256Function · 0.70
getMethod · 0.65

Tested by

no test coverage detected