semgrep problems fix
This commit is contained in:
@@ -4,6 +4,7 @@ import path from 'path'
|
||||
import { promises as fs } from 'fs'
|
||||
import {
|
||||
getBackupDirectoryForDataFile,
|
||||
resolveDataFileBackupPath,
|
||||
listDataFileBackups,
|
||||
restoreDataFileBackup,
|
||||
writeDataFileWithRotation
|
||||
@@ -60,7 +61,7 @@ describe('Data file rotation utility', () => {
|
||||
expect(backups.length).toBe(1)
|
||||
|
||||
const backupDir = getBackupDirectoryForDataFile(dataFile)
|
||||
const backupContent = await fs.readFile(path.join(backupDir, backups[0]), 'utf-8')
|
||||
const backupContent = await fs.readFile(resolveDataFileBackupPath(backupDir, backups[0]), 'utf-8')
|
||||
expect(backupContent).toBe('v1')
|
||||
|
||||
const currentContent = await fs.readFile(dataFile, 'utf-8')
|
||||
@@ -91,7 +92,7 @@ describe('Data file rotation utility', () => {
|
||||
|
||||
const backupDir = getBackupDirectoryForDataFile(dataFile)
|
||||
const backupContents = await Promise.all(
|
||||
backups.map((name) => fs.readFile(path.join(backupDir, name), 'utf-8'))
|
||||
backups.map((name) => fs.readFile(resolveDataFileBackupPath(backupDir, name), 'utf-8'))
|
||||
)
|
||||
|
||||
expect(backupContents).toEqual(expect.arrayContaining(['v2', 'v3']))
|
||||
@@ -109,7 +110,7 @@ describe('Data file rotation utility', () => {
|
||||
const resolved = await Promise.all(
|
||||
beforeRestoreBackups.map(async (name) => ({
|
||||
name,
|
||||
content: await fs.readFile(path.join(backupDir, name), 'utf-8')
|
||||
content: await fs.readFile(resolveDataFileBackupPath(backupDir, name), 'utf-8')
|
||||
}))
|
||||
)
|
||||
const v1Entry = resolved.find((entry) => entry.content === 'v1')
|
||||
@@ -124,7 +125,7 @@ describe('Data file rotation utility', () => {
|
||||
|
||||
const afterRestoreBackups = await listDataFileBackups(dataFile)
|
||||
const afterContents = await Promise.all(
|
||||
afterRestoreBackups.map((name) => fs.readFile(path.join(backupDir, name), 'utf-8'))
|
||||
afterRestoreBackups.map((name) => fs.readFile(resolveDataFileBackupPath(backupDir, name), 'utf-8'))
|
||||
)
|
||||
|
||||
expect(afterContents).toContain('v3')
|
||||
|
||||
Reference in New Issue
Block a user