Files
smartarchive/test/test.ts
Juergen Kunz b5a3793ed5 fix: update import path for tapbundle and refactor download logic
- Changed the import path for tapbundle from '@push.rocks/tapbundle' to '@git.zone/tstest/tapbundle'.
- Refactored the download logic in the preTask for preparing downloads to use SmartRequest for better handling of the response.
- Added a new pnpm workspace configuration file to specify only built dependencies.
2025-08-18 00:47:24 +00:00

50 lines
1.6 KiB
TypeScript

import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as plugins from './plugins.js';
const testPaths = {
nogitDir: plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'../.nogit/'
),
remoteDir: plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'../.nogit/remote'
),
};
import * as smartarchive from '../ts/index.js';
tap.preTask('should prepare .nogit dir', async () => {
await plugins.smartfile.fs.ensureDir(testPaths.remoteDir);
});
tap.preTask('should prepare downloads', async (tools) => {
const response = await plugins.smartrequest.SmartRequest.create()
.url('https://verdaccio.lossless.digital/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz')
.get();
const downloadedFile: Buffer = Buffer.from(await response.arrayBuffer());
await plugins.smartfile.memory.toFs(
downloadedFile,
plugins.path.join(testPaths.nogitDir, 'test.tgz')
);
});
tap.test('should extract existing files on disk', async () => {
const testSmartarchive = await smartarchive.SmartArchive.fromArchiveUrl(
'https://verdaccio.lossless.digital/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
);
await testSmartarchive.exportToFs(testPaths.nogitDir);
});
tap.skip.test('should extract a b2zip', async () => {
const dataUrl = 'https://daten.offeneregister.de/de_companies_ocdata.jsonl.bz2';
const testArchive = await smartarchive.SmartArchive.fromArchiveUrl(dataUrl);
await testArchive.exportToFs(
plugins.path.join(testPaths.nogitDir, 'de_companies_ocdata.jsonl'),
'data.jsonl',
);
})
await tap.start();