mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
SEARCH-563
- Fixed unit tests
This commit is contained in:
parent
7b71c8f2dc
commit
b32c7784ea
@ -115,6 +115,12 @@ class Search {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fs.existsSync(this.dataFolder)) {
|
||||
log.send(logLevels.ERROR, 'User index folder not found');
|
||||
reject(new Error('User index folder not found'));
|
||||
return;
|
||||
}
|
||||
|
||||
const indexId = randomString.generate(searchConfig.BATCH_RANDOM_INDEX_PATH_LENGTH);
|
||||
libSymphonySearch.symSECreatePartialIndexAsync(this.batchIndex, indexId, messages, (err, res) => {
|
||||
if (err) {
|
||||
@ -133,6 +139,13 @@ class Search {
|
||||
*/
|
||||
mergeIndexBatches() {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
if (!fs.existsSync(this.dataFolder)) {
|
||||
log.send(logLevels.ERROR, 'User index folder not found');
|
||||
reject(new Error('User index folder not found'));
|
||||
return;
|
||||
}
|
||||
|
||||
libSymphonySearch.symSEMergePartialIndexAsync(this.indexFolderName, this.batchIndex, (err, res) => {
|
||||
if (err) {
|
||||
log.send(logLevels.ERROR, 'Error merging the index ->' + err);
|
||||
@ -186,6 +199,11 @@ class Search {
|
||||
throw new Error('Library not initialized');
|
||||
}
|
||||
|
||||
if (!fs.existsSync(this.dataFolder)) {
|
||||
log.send(logLevels.ERROR, 'User index folder not found');
|
||||
throw new Error('User index folder not found');
|
||||
}
|
||||
|
||||
this.isRealTimeIndexing = true;
|
||||
return libSymphonySearch.symSEIndexRealTimeAsync(this.realTimeIndex, message, (err, result) => {
|
||||
this.isRealTimeIndexing = false;
|
||||
|
@ -54,7 +54,9 @@ describe('Tests for Search', function() {
|
||||
realTimeIndexPath = path.join(userConfigDir, 'data', 'temp_realtime_index');
|
||||
tempBatchPath = path.join(userConfigDir, 'data', 'temp_batch_indexes');
|
||||
dataFolderPath = path.join(searchConfig.FOLDERS_CONSTANTS.EXEC_PATH, '..', 'data');
|
||||
|
||||
if (fs.existsSync(dataFolderPath)) {
|
||||
fs.unlinkSync(dataFolderPath)
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -347,7 +349,7 @@ describe('Tests for Search', function() {
|
||||
|
||||
expect(function () {
|
||||
SearchApi.realTimeIndexing()
|
||||
}).toThrow(new Error('RealTime Indexing: Messages is required'));
|
||||
}).toThrow();
|
||||
|
||||
SearchApi.isInitialized = false;
|
||||
expect(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user