2018-03-31 03:30:30 +08:00
|
|
|
import {expect} from 'chai';
|
|
|
|
import * as path from 'path';
|
2019-12-10 17:44:35 +08:00
|
|
|
import {Config} from '../../../../../src/common/config/private/Config';
|
|
|
|
import {ProjectPath} from '../../../../../src/backend/ProjectPath';
|
|
|
|
import {Utils} from '../../../../../src/common/Utils';
|
2021-05-11 22:44:17 +08:00
|
|
|
import {DatabaseType} from '../../../../../src/common/config/private/PrivateConfig';
|
2023-10-14 23:54:21 +08:00
|
|
|
import {DiskManager} from '../../../../../src/backend/model/fileaccess/DiskManager';
|
2021-05-11 22:44:17 +08:00
|
|
|
|
|
|
|
declare const before: any;
|
2017-07-16 03:04:41 +08:00
|
|
|
|
|
|
|
describe('DiskMangerWorker', () => {
|
2021-05-11 22:44:17 +08:00
|
|
|
// loading default settings (this might have been changed by other tests)
|
|
|
|
before(() => {
|
|
|
|
Config.loadSync();
|
2022-12-29 02:12:18 +08:00
|
|
|
Config.Database.type = DatabaseType.sqlite;
|
|
|
|
Config.Faces.enabled = true;
|
|
|
|
Config.Faces.keywordsToPersons = true;
|
2023-11-17 06:41:05 +08:00
|
|
|
Config.Extensions.enabled = false;
|
2021-05-11 22:44:17 +08:00
|
|
|
});
|
|
|
|
|
2017-07-16 03:04:41 +08:00
|
|
|
|
2017-07-16 20:03:16 +08:00
|
|
|
it('should parse metadata', async () => {
|
2022-12-29 02:12:18 +08:00
|
|
|
Config.Media.folder = path.join(__dirname, '/../../../assets');
|
2020-01-08 05:28:59 +08:00
|
|
|
ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets');
|
2023-10-14 23:54:21 +08:00
|
|
|
const dir = await DiskManager.scanDirectory('/');
|
2020-12-28 00:36:29 +08:00
|
|
|
// should match the number of media (photo/video) files in the assets folder
|
2023-11-27 05:47:57 +08:00
|
|
|
expect(dir.media.length).to.be.equals(11);
|
2023-11-17 06:41:05 +08:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
2020-01-08 05:28:59 +08:00
|
|
|
const expected = require(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.json'));
|
2021-03-27 17:23:48 +08:00
|
|
|
const i = dir.media.findIndex(m => m.name === 'test image öüóőúéáű-.,.jpg');
|
|
|
|
expect(Utils.clone(dir.media[i].name)).to.be.deep.equal('test image öüóőúéáű-.,.jpg');
|
|
|
|
expect(Utils.clone(dir.media[i].metadata)).to.be.deep.equal(expected);
|
2017-07-16 03:04:41 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|