1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/test/common/unit/config/Config.ts

26 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-04-15 21:05:19 +08:00
import {expect} from 'chai';
2024-04-16 03:03:03 +08:00
import {ConfigClassBuilder} from 'typeconfig/node';
2024-04-15 21:05:19 +08:00
import {ExtensionConfigWrapper} from '../../../../src/backend/model/extension/ExtensionConfigWrapper';
2024-04-16 03:03:03 +08:00
import {TestHelper} from '../../../TestHelper';
import * as fs from 'fs';
2024-04-15 21:05:19 +08:00
describe('Config', () => {
2024-04-16 03:03:03 +08:00
beforeEach(async () => {
await fs.promises.rm(TestHelper.TMP_DIR, {recursive: true, force: true});
});
afterEach(async () => {
await fs.promises.rm(TestHelper.TMP_DIR, {recursive: true, force: true});
});
2024-04-15 21:05:19 +08:00
it('should load default from env', () => {
2024-04-16 03:03:03 +08:00
process.env['default-Media-tempFolder'] = 'test/test';
2024-04-15 21:05:19 +08:00
const conf = ExtensionConfigWrapper.originalSync();
2024-04-16 03:03:03 +08:00
expect(conf.Media.tempFolder).to.be.equal('test/test');
2024-04-15 21:05:19 +08:00
expect(ConfigClassBuilder.attachPrivateInterface(conf.Media).__defaults.tempFolder).to.be.equal('test/test');
expect(process.env['default-Media-tempFolder']).to.be.equal('test/test');
const conf2 = ExtensionConfigWrapper.originalSync();
expect(ConfigClassBuilder.attachPrivateInterface(conf2.Media).__defaults.tempFolder).to.be.equal('test/test');
2024-04-16 03:03:03 +08:00
expect(conf2.Media.tempFolder).to.be.equal('test/test');
2024-04-15 21:05:19 +08:00
});
});