2018-03-30 21:30:30 +02:00
|
|
|
import {expect} from 'chai';
|
2019-12-10 11:44:35 +02:00
|
|
|
import {DiskMangerWorker} from '../../../../../src/backend/model/threading/DiskMangerWorker';
|
2018-03-30 21:30:30 +02:00
|
|
|
import * as path from 'path';
|
2019-12-10 11:44:35 +02:00
|
|
|
import {Config} from '../../../../../src/common/config/private/Config';
|
|
|
|
import {ProjectPath} from '../../../../../src/backend/ProjectPath';
|
|
|
|
import {Utils} from '../../../../../src/common/Utils';
|
2021-05-11 16:44:17 +02:00
|
|
|
import {DatabaseType} from '../../../../../src/common/config/private/PrivateConfig';
|
|
|
|
|
|
|
|
declare const before: any;
|
2017-07-15 21:04:41 +02:00
|
|
|
|
|
|
|
describe('DiskMangerWorker', () => {
|
2021-05-11 16:44:17 +02:00
|
|
|
// loading default settings (this might have been changed by other tests)
|
|
|
|
before(() => {
|
|
|
|
Config.loadSync();
|
|
|
|
Config.Server.Database.type = DatabaseType.sqlite;
|
|
|
|
Config.Client.Faces.enabled = true;
|
|
|
|
Config.Client.Faces.keywordsToPersons = true;
|
|
|
|
});
|
|
|
|
|
2017-07-15 21:04:41 +02:00
|
|
|
|
2017-07-16 14:03:16 +02:00
|
|
|
it('should parse metadata', async () => {
|
2020-01-07 23:28:59 +02:00
|
|
|
Config.Server.Media.folder = path.join(__dirname, '/../../../assets');
|
|
|
|
ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets');
|
2018-03-30 21:30:30 +02:00
|
|
|
const dir = await DiskMangerWorker.scanDirectory('/');
|
2020-12-27 18:36:29 +02:00
|
|
|
// should match the number of media (photo/video) files in the assets folder
|
2021-04-26 15:22:12 +02:00
|
|
|
expect(dir.media.length).to.be.equals(8);
|
2020-01-07 23:28:59 +02:00
|
|
|
const expected = require(path.join(__dirname, '/../../../assets/test image öüóőúéáű-.,.json'));
|
2021-03-27 11:23:48 +02: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-15 21:04:41 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|