1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Improving saved search pg2conf tests

This commit is contained in:
Patrik J. Braun 2021-05-30 18:18:24 +02:00
parent b126022454
commit 30c2497f8f
4 changed files with 8 additions and 7 deletions

View File

@ -173,8 +173,7 @@ export class AuthenticationMWs {
return next();
} catch (err) {
console.error(err);
return next(new ErrorDTO(ErrorCodes.CREDENTIAL_NOT_FOUND, 'credentials not found during login'));
return next(new ErrorDTO(ErrorCodes.CREDENTIAL_NOT_FOUND, 'credentials not found during login', err));
}

View File

@ -41,7 +41,7 @@ export class IndexingManager implements IIndexingManager {
if (ServerPG2ConfMap[f.name] === ServerSidePG2ConfAction.SAVED_SEARCH) {
const fullMediaPath = path.join(ProjectPath.ImageFolder, f.directory.path, f.directory.name, f.name);
Logger.silly(LOG_TAG, 'Saving saved searches to DB from:', fullMediaPath);
Logger.silly(LOG_TAG, 'Saving saved-searches to DB from:', fullMediaPath);
const savedSearches: { name: string, searchQuery: SearchQueryDTO }[] =
JSON.parse(await fs.promises.readFile(fullMediaPath, 'utf8'));
for (const s of savedSearches) {
@ -363,7 +363,7 @@ export class IndexingManager implements IIndexingManager {
this.isSaving = true;
try {
const connection = await SQLConnection.getConnection();
const serverSideConfigs = scannedDirectory.metaFile.filter(m => ServerPG2ConfMap[m.name]);
const serverSideConfigs = scannedDirectory.metaFile.filter(m => !!ServerPG2ConfMap[m.name]);
scannedDirectory.metaFile = scannedDirectory.metaFile.filter(m => !ServerPG2ConfMap[m.name]);
const currentDirId: number = await this.saveParentDir(connection, scannedDirectory);
await this.saveChildDirs(connection, currentDirId, scannedDirectory);
@ -372,8 +372,6 @@ export class IndexingManager implements IIndexingManager {
await ObjectManagers.getInstance().PersonManager.onGalleryIndexUpdate();
await ObjectManagers.getInstance().VersionManager.updateDataVersion();
await IndexingManager.processServerSidePG2Conf(serverSideConfigs);
} catch (e) {
throw e;
} finally {
this.isSaving = false;
}

View File

@ -22,6 +22,7 @@ export const PG2ConfMap = {
export enum ServerSidePG2ConfAction {
// Enum always starts from 1 as !!0 === false
SAVED_SEARCH = 1
}

View File

@ -583,15 +583,18 @@ describe('IndexingManager', (sqlHelper: DBTestHelper) => {
it('.saved_searches.pg2conf', async () => {
Config.Server.Threading.enabled = false;
Config.Client.Album.enabled = true;
Config.Server.Media.folder = path.join(__dirname, '/../../../assets');
ProjectPath.ImageFolder = path.join(__dirname, '/../../../assets');
const im = new IndexingManagerTest();
const am = new AlbumManager();
const dir = await DiskManager.scanDirectory('/');
await im.saveToDB(dir);
const albums = await am.getAlbums();
expect(albums[0].preview).to.be.an('object');
// expect(albums[0].preview).to.be.an('object');
delete albums[0].preview;
expect(albums).to.be.equalInAnyOrder([
{