2023-05-11 21:49:07 +03:00
|
|
|
import chai from 'chai'
|
|
|
|
|
|
|
|
import { ErrorUtils } from '@tornado/sdk-utils'
|
2023-05-13 22:30:21 +03:00
|
|
|
import { Cache, Files } from '@tornado/sdk-data'
|
2023-05-11 21:49:07 +03:00
|
|
|
|
|
|
|
const expect = chai.expect
|
|
|
|
|
|
|
|
describe('data', () => {
|
|
|
|
if (!process.env.EXPORT_TEST_DIRNAME)
|
|
|
|
throw ErrorUtils.getError('data.test.ts: no cache test dirname provided')
|
|
|
|
|
2023-05-13 22:30:21 +03:00
|
|
|
it(`Files.gzipSync: should be able to zip dir`, () => {
|
|
|
|
const filepath = Files.getCachePath(process.env.EXPORT_TEST_DIRNAME!)
|
|
|
|
Files.gzipSync(filepath, filepath)
|
|
|
|
})
|
|
|
|
|
|
|
|
it(`Files.gunzipSync: should be able to unzip dir`, () => {
|
|
|
|
const filepath = Files.getCachePath(process.env.EXPORT_TEST_DIRNAME!)
|
|
|
|
Files.gunzipSync(filepath, Files.getCachePath())
|
|
|
|
})
|
|
|
|
|
2023-05-31 23:53:28 +03:00
|
|
|
it(`Cache.jsonify: should be able to write db docs to json`, async () => {
|
|
|
|
const cache = new Cache.Base(process.env.EXPORT_TEST_DIRNAME!)
|
|
|
|
await cache.jsonify()
|
|
|
|
})
|
|
|
|
|
2023-05-13 22:30:21 +03:00
|
|
|
it(`Cache.zip: should be able to zip or load from zip ${process.env.EXPORT_TEST_DIRNAME}`, async () => {
|
2023-05-11 21:49:07 +03:00
|
|
|
const cache = new Cache.Base(process.env.EXPORT_TEST_DIRNAME!)
|
2023-05-13 22:30:21 +03:00
|
|
|
await cache.zip(undefined, true)
|
2023-05-11 21:49:07 +03:00
|
|
|
}).timeout(0)
|
|
|
|
})
|