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;
|
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);
|
const indexId = randomString.generate(searchConfig.BATCH_RANDOM_INDEX_PATH_LENGTH);
|
||||||
libSymphonySearch.symSECreatePartialIndexAsync(this.batchIndex, indexId, messages, (err, res) => {
|
libSymphonySearch.symSECreatePartialIndexAsync(this.batchIndex, indexId, messages, (err, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -133,6 +139,13 @@ class Search {
|
|||||||
*/
|
*/
|
||||||
mergeIndexBatches() {
|
mergeIndexBatches() {
|
||||||
return new Promise((resolve, reject) => {
|
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) => {
|
libSymphonySearch.symSEMergePartialIndexAsync(this.indexFolderName, this.batchIndex, (err, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.send(logLevels.ERROR, 'Error merging the index ->' + err);
|
log.send(logLevels.ERROR, 'Error merging the index ->' + err);
|
||||||
@ -186,6 +199,11 @@ class Search {
|
|||||||
throw new Error('Library not initialized');
|
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;
|
this.isRealTimeIndexing = true;
|
||||||
return libSymphonySearch.symSEIndexRealTimeAsync(this.realTimeIndex, message, (err, result) => {
|
return libSymphonySearch.symSEIndexRealTimeAsync(this.realTimeIndex, message, (err, result) => {
|
||||||
this.isRealTimeIndexing = false;
|
this.isRealTimeIndexing = false;
|
||||||
|
@ -54,7 +54,9 @@ describe('Tests for Search', function() {
|
|||||||
realTimeIndexPath = path.join(userConfigDir, 'data', 'temp_realtime_index');
|
realTimeIndexPath = path.join(userConfigDir, 'data', 'temp_realtime_index');
|
||||||
tempBatchPath = path.join(userConfigDir, 'data', 'temp_batch_indexes');
|
tempBatchPath = path.join(userConfigDir, 'data', 'temp_batch_indexes');
|
||||||
dataFolderPath = path.join(searchConfig.FOLDERS_CONSTANTS.EXEC_PATH, '..', 'data');
|
dataFolderPath = path.join(searchConfig.FOLDERS_CONSTANTS.EXEC_PATH, '..', 'data');
|
||||||
|
if (fs.existsSync(dataFolderPath)) {
|
||||||
|
fs.unlinkSync(dataFolderPath)
|
||||||
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -347,7 +349,7 @@ describe('Tests for Search', function() {
|
|||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
SearchApi.realTimeIndexing()
|
SearchApi.realTimeIndexing()
|
||||||
}).toThrow(new Error('RealTime Indexing: Messages is required'));
|
}).toThrow();
|
||||||
|
|
||||||
SearchApi.isInitialized = false;
|
SearchApi.isInitialized = false;
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user