smartarchive/test/test.ts

51 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-07-26 14:13:33 +00:00
import { tap, expect } from '@push.rocks/tapbundle';
2020-03-16 14:38:17 +00:00
2023-11-06 17:14:21 +00:00
import * as plugins from './plugins.js';
2020-03-16 14:38:17 +00:00
const testPaths = {
2023-11-06 17:14:21 +00:00
nogitDir: plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
2023-07-26 14:13:33 +00:00
'../.nogit/'
),
2023-11-06 17:14:21 +00:00
remoteDir: plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
2023-07-26 14:13:33 +00:00
'../.nogit/remote'
),
2020-03-16 15:13:58 +00:00
};
2020-03-16 14:38:17 +00:00
2022-04-04 12:15:51 +00:00
import * as smartarchive from '../ts/index.js';
2020-03-16 14:38:17 +00:00
tap.preTask('should prepare .nogit dir', async () => {
2023-11-06 17:14:21 +00:00
await plugins.smartfile.fs.ensureDir(testPaths.remoteDir);
2020-03-13 20:22:56 +00:00
});
2021-04-19 11:49:25 +00:00
tap.preTask('should prepare downloads', async (tools) => {
2020-03-16 14:38:17 +00:00
const downloadedFile: Buffer = (
2023-11-06 17:14:21 +00:00
await plugins.smartrequest.getBinary(
2023-07-26 14:13:33 +00:00
'https://verdaccio.lossless.digital/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
2020-03-16 15:13:58 +00:00
)
2020-03-16 14:38:17 +00:00
).body;
2023-11-06 17:14:21 +00:00
await plugins.smartfile.memory.toFs(
2020-03-16 15:13:58 +00:00
downloadedFile,
2023-11-06 17:14:21 +00:00
plugins.path.join(testPaths.nogitDir, 'test.tgz')
2020-03-16 15:13:58 +00:00
);
2020-03-16 14:38:17 +00:00
});
2020-03-17 00:21:05 +00:00
tap.test('should extract existing files on disk', async () => {
2023-11-06 17:14:21 +00:00
const testSmartarchive = await smartarchive.SmartArchive.fromArchiveUrl(
2023-07-26 14:13:33 +00:00
'https://verdaccio.lossless.digital/@pushrocks%2fwebsetup/-/websetup-2.0.14.tgz'
);
2023-11-07 03:19:54 +00:00
await testSmartarchive.exportToFs(testPaths.nogitDir);
2020-03-16 17:04:17 +00:00
});
2023-11-14 09:58:01 +00:00
tap.skip.test('should extract a b2zip', async () => {
2023-11-07 03:19:54 +00:00
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',
);
})
2023-11-14 09:55:19 +00:00
await tap.start();