mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo.git
synced 2026-09-21 16:52:01 -07:00
- Add tests for profile/level handleError to raise coverage - Extract DbBackup pure helpers into testable db-backup-util module - Add tests for DbBackup zip/unzip and the pure helpers - Extract shared handleControllerError helper across 7 REST controllers By refactorer.
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
/*
|
|
Unit tests for DbBackup pure helpers.
|
|
*/
|
|
|
|
import { assert } from 'chai'
|
|
import {
|
|
zipFileName,
|
|
oldBackupHeight,
|
|
oldBackupZipPath,
|
|
backupFilePath
|
|
} from '../../../src/adapters/lib/db-backup-util.js'
|
|
|
|
describe('#DbBackupUtil', () => {
|
|
describe('zipFileName', () => {
|
|
it('builds the zip file name for a height', () => {
|
|
assert.equal(zipFileName(600000), 'memo-indexer-600000.zip')
|
|
})
|
|
})
|
|
|
|
describe('oldBackupHeight', () => {
|
|
it('computes the height of the oldest retained backup', () => {
|
|
assert.equal(oldBackupHeight(600000, 1, 3), 599997)
|
|
assert.equal(oldBackupHeight(600000, 2, 3), 599994)
|
|
})
|
|
})
|
|
|
|
describe('oldBackupZipPath', () => {
|
|
it('builds the zips-relative path for an old backup', () => {
|
|
assert.equal(oldBackupZipPath(599997), 'zips/memo-indexer-599997.zip')
|
|
})
|
|
})
|
|
|
|
describe('backupFilePath', () => {
|
|
it('builds the absolute zip file path for a height', () => {
|
|
assert.equal(backupFilePath('/data/leveldb', 600000), '/data/leveldb/zips/memo-indexer-600000.zip')
|
|
})
|
|
})
|
|
})
|