4e21ca937a
Deploy Documentation / deploy (push) Has been cancelled
Canary / Prepare Version (push) Has been cancelled
Canary / build-cli (push) Has been cancelled
Canary / Upload Install Script (push) Has been cancelled
Canary / bundle-desktop (push) Has been cancelled
Canary / bundle-desktop-intel (push) Has been cancelled
Canary / bundle-desktop-linux (push) Has been cancelled
Canary / bundle-desktop-windows (push) Has been cancelled
Canary / bundle-desktop-windows-cuda (push) Has been cancelled
Canary / Release (push) Has been cancelled
Unused Dependencies / machete (push) Has been cancelled
CI / changes (push) Has been cancelled
CI / Check Rust Code Format (push) Has been cancelled
CI / Build and Test Rust Project (push) Has been cancelled
CI / Build Rust Project on Windows (push) Has been cancelled
CI / Check MSRV (push) Has been cancelled
CI / Lint Rust Code (push) Has been cancelled
CI / Check Generated Schemas are Up-to-Date (push) Has been cancelled
CI / Test and Lint Electron Desktop App (push) Has been cancelled
CI / H5 Plaza Tests and Build (push) Has been cancelled
Live Provider Tests / check-fork (push) Has been cancelled
Live Provider Tests / changes (push) Has been cancelled
Live Provider Tests / Build Binary (push) Has been cancelled
Live Provider Tests / Smoke Tests (push) Has been cancelled
Live Provider Tests / Smoke Tests (Code Execution) (push) Has been cancelled
Live Provider Tests / Compaction Tests (push) Has been cancelled
Live Provider Tests / goose server HTTP integration tests (push) Has been cancelled
Publish Ask AI Bot Docker Image / docker (push) Has been cancelled
Publish Docker Image / docker (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Fork goose with custom MCP widgets, platform extensions (aider, git, web, search), MindSpace H5 backend/frontend, Plaza/Ops UIs, and deploy scripts for tkmind.cn. Co-authored-by: Cursor <cursoragent@cursor.com>
61 lines
2.2 KiB
JavaScript
61 lines
2.2 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import test from 'node:test';
|
|
import {
|
|
ensureUserZoneDirs,
|
|
mirrorAssetToZone,
|
|
resolveUserWorkspaceRoot,
|
|
syncUserZonesFromAssets,
|
|
UPLOAD_ZONE_CODES,
|
|
} from './user-space.mjs';
|
|
|
|
test('user workspace is MindSpace/<username> with zone subdirs', () => {
|
|
const h5Root = fs.mkdtempSync(path.join(os.tmpdir(), 'h5-'));
|
|
const workspace = resolveUserWorkspaceRoot(h5Root, { username: 'john' });
|
|
assert.ok(workspace.endsWith(`${path.sep}MindSpace${path.sep}john`));
|
|
ensureUserZoneDirs(workspace);
|
|
for (const code of UPLOAD_ZONE_CODES) {
|
|
assert.ok(fs.existsSync(path.join(workspace, code)));
|
|
}
|
|
});
|
|
|
|
test('mirrorAssetToZone copies upload into oa/', () => {
|
|
const h5Root = fs.mkdtempSync(path.join(os.tmpdir(), 'h5-'));
|
|
const workspace = resolveUserWorkspaceRoot(h5Root, { username: 'john' });
|
|
const source = path.join(h5Root, 'source.csv');
|
|
fs.writeFileSync(source, 'a,b\n1,2\n');
|
|
const dest = mirrorAssetToZone({
|
|
workspaceRoot: workspace,
|
|
categoryCode: 'oa',
|
|
filename: 'export.csv',
|
|
sourcePath: source,
|
|
});
|
|
assert.equal(dest, path.join(workspace, 'oa', 'export.csv'));
|
|
assert.equal(fs.readFileSync(dest, 'utf8'), 'a,b\n1,2\n');
|
|
});
|
|
|
|
test('syncUserZonesFromAssets backfills from canonical storage', async () => {
|
|
const h5Root = fs.mkdtempSync(path.join(os.tmpdir(), 'h5-'));
|
|
const storageRoot = path.join(h5Root, 'data', 'mindspace');
|
|
const userId = 'user-1';
|
|
const storageKey = path.posix.join('users', userId, 'assets', 'a1', 'versions', 'v1');
|
|
const sourcePath = path.join(storageRoot, storageKey);
|
|
fs.mkdirSync(path.dirname(sourcePath), { recursive: true });
|
|
fs.writeFileSync(sourcePath, 'col\nval\n');
|
|
const workspace = resolveUserWorkspaceRoot(h5Root, { username: 'john' });
|
|
const pool = {
|
|
async query() {
|
|
return [
|
|
[{ original_filename: '2025-12-06T13-34_export.csv', category_code: 'oa', storage_key: storageKey }],
|
|
];
|
|
},
|
|
};
|
|
const result = await syncUserZonesFromAssets(pool, storageRoot, userId, workspace);
|
|
assert.equal(result.mirrored, 1);
|
|
assert.ok(
|
|
fs.existsSync(path.join(workspace, 'oa', '2025-12-06T13-34_export.csv')),
|
|
);
|
|
});
|