test: add aggregations and mapping test

This commit is contained in:
wulkanat@gmail.com
2020-09-09 18:01:25 +02:00
parent e5511d0738
commit 24ea449dd4
38 changed files with 1945 additions and 3 deletions

View File

@@ -87,7 +87,7 @@ commander
commander
.command('mapping <relativeSrcPath>')
.option('-m, --mappingPath <relativeMappingPath>', 'Mapping Path')
.option('-i, --ignoredTags <ignoredTags>', 'Ignored Tags')
.option('-i, --ignoredTags <ignoredTags>', 'Ignored Tags (comma-separated)')
.option('-a, --aggPath <relativeAggregationPath>', 'Aggregations Path')
.option('-e, --errorPath <relativeErrorPath>', 'Error Path')
.action(async (relativeSrcPath, options) => {

View File

@@ -573,8 +573,12 @@ function readTypeTags(type: string, path: string, topTypeName: string, tags: Com
* @param projectReflection a reflection of the project you want to get the ES Mappings from
* @param ignoredTags the tag names for which the error output should be suppressed
* @param showErrorOutput whether to print all errors in the command line or not
* @param interfaceFilter only parse specific interfaces, this is for testing purposes
*/
export function generateTemplate(projectReflection: ProjectReflection, ignoredTags: string[], showErrorOutput = true):
export function generateTemplate(projectReflection: ProjectReflection,
ignoredTags: string[],
showErrorOutput = true,
interfaceFilter: string[] = []):
// tslint:disable-next-line:completed-docs
{ aggregations: AggregationSchema; errors: string[]; mappings: ElasticsearchTemplateCollection; } {
errors = [];
@@ -626,6 +630,13 @@ export function generateTemplate(projectReflection: ProjectReflection, ignoredTa
Logger.error(`The interface ${_interface.name} is required to use an SCThingType as a type, please do so.`);
}
// filter out
if (interfaceFilter.length !== 0) {
if (typeof interfaceFilter.find((it) => it === typeName) === 'undefined') {
continue;
}
}
// init aggregation schema for type
aggregations[typeName] = {
aggs: {},

View File

@@ -207,7 +207,7 @@ export interface ElasticsearchObject {
* Fields that should be excluded in the _source field
*/
excludes: [
'creation_date',
'creation_date'
];
};