Don't mkdir restore dir in updater

This commit is contained in:
Fedor Indutny 2022-03-04 11:59:47 -08:00 committed by GitHub
parent effe5aae6f
commit df7cdfacc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 96 additions and 21 deletions

View file

@ -2,6 +2,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { pathExists } from 'fs-extra';
import { stat, mkdir } from 'fs/promises';
import { join } from 'path';
import {
createUpdateCacheDirIfNeeded,
@ -10,6 +13,9 @@ import {
isUpdateFileNameValid,
validatePath,
parseYaml,
createTempDir,
getTempDir,
deleteTempDir,
} from '../../updater/common';
describe('updater/signatures', () => {
@ -152,4 +158,32 @@ releaseDate: '2021-12-03T19:00:23.754Z'
});
});
});
describe('createTempDir', () => {
it('creates a temporary directory', async () => {
const dir = await createTempDir();
assert.isTrue((await stat(dir)).isDirectory());
await deleteTempDir(dir);
assert.isFalse(await pathExists(dir), 'Directory should be deleted');
});
});
describe('getTempDir', () => {
it('reserves a temporary directory', async () => {
const dir = await getTempDir();
assert.isTrue(
(await stat(join(dir, '..'))).isDirectory(),
'Parent folder should exist'
);
assert.isFalse(await pathExists(dir), 'Reserved folder should not exist');
await mkdir(dir);
await deleteTempDir(dir);
assert.isFalse(await pathExists(dir), 'Directory should be deleted');
});
});
});