mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-08 22:42:54 +00:00
feat: update tests
feat: update tests feat: update tests
This commit is contained in:
@@ -12,45 +12,22 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {readdirSync, statSync} from 'fs';
|
||||
import path from 'path';
|
||||
import {MapAggTest} from './mapping-model/map-agg-test.js';
|
||||
import {MapAggTestOptions} from './mapping-model/map-agg-test-options.js';
|
||||
import {MapAggTest} from './mapping-model/map-agg-test';
|
||||
import {MapAggTestOptions} from './mapping-model/map-agg-test-options';
|
||||
import {expandPathToFilesSync} from './common';
|
||||
|
||||
describe('ES Aggregation Gen', async () => {
|
||||
const magAppInstance = new MapAggTest('aggregations');
|
||||
|
||||
/**
|
||||
* Expand a path to a list of all files deeply contained in it
|
||||
*/
|
||||
function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
|
||||
const fullPath = path.resolve(sourcePath);
|
||||
const directory = statSync(fullPath);
|
||||
|
||||
return directory.isDirectory()
|
||||
? // eslint-disable-next-line unicorn/prefer-spread
|
||||
([] as string[]).concat(
|
||||
...readdirSync(fullPath).map(fragment =>
|
||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||
),
|
||||
)
|
||||
: [fullPath].filter(accept);
|
||||
}
|
||||
|
||||
for (const file of expandPathToFilesSync('./test/mapping-model/aggregations/', file =>
|
||||
file.endsWith('agg-test.ts'),
|
||||
)) {
|
||||
try {
|
||||
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
||||
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
||||
|
||||
it(test.testName, function () {
|
||||
magAppInstance.testInterfaceAgainstPath(test);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('UNHANDLED REJECTION', (error as any).stack);
|
||||
process.exit(1);
|
||||
}
|
||||
it(test.testName, function () {
|
||||
magAppInstance.testInterfaceAgainstPath(test);
|
||||
});
|
||||
}
|
||||
})
|
||||
.timeout(20_000)
|
||||
|
||||
19
packages/es-mapping-generator/test/common.ts
Normal file
19
packages/es-mapping-generator/test/common.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import path from 'path';
|
||||
import {readdirSync, statSync} from 'fs';
|
||||
|
||||
/**
|
||||
* Expand a path to a list of all files deeply contained in it
|
||||
*/
|
||||
export function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
|
||||
const fullPath = path.resolve(sourcePath);
|
||||
const directory = statSync(fullPath);
|
||||
|
||||
return directory.isDirectory()
|
||||
? // eslint-disable-next-line unicorn/prefer-spread
|
||||
([] as string[]).concat(
|
||||
...readdirSync(fullPath).map(fragment =>
|
||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||
),
|
||||
)
|
||||
: [fullPath].filter(accept);
|
||||
}
|
||||
@@ -13,8 +13,8 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export enum ThingType {
|
||||
AggArray = 'agg array',
|
||||
AggGlobal = 'agg global',
|
||||
AggGlobalNested = 'agg global nested',
|
||||
AggNested = 'agg nested',
|
||||
AggInherited = 'agg inherited',
|
||||
AggInheritedGlobal = 'agg inherited global',
|
||||
AggInheritedOverwritten = 'agg inherited overwritten',
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {MappingDynamicTemplate, MappingProperty} from '@elastic/elasticsearch/lib/api/types';
|
||||
|
||||
export interface MapAggTestOptions {
|
||||
testName: string;
|
||||
name: string;
|
||||
agg?: {
|
||||
fields?: string[];
|
||||
globals?: string[];
|
||||
};
|
||||
map?: MinimalMappingDescription;
|
||||
err?: string[];
|
||||
ignoredTags?: string[];
|
||||
}
|
||||
|
||||
export interface MinimalMappingDescription {
|
||||
maps?: {
|
||||
[name: string]: MappingProperty;
|
||||
};
|
||||
dynamicTemplates?: Record<string, MappingDynamicTemplate>[];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {
|
||||
generateTemplate,
|
||||
getProjectReflection,
|
||||
AggregationSchema,
|
||||
ESNestedAggregation,
|
||||
ElasticsearchTemplateCollection,
|
||||
settings,
|
||||
} from '../../src';
|
||||
import path from 'path';
|
||||
import {expect} from 'chai';
|
||||
import {ProjectReflection} from 'typedoc';
|
||||
import {MapAggTestOptions, MinimalMappingDescription} from './map-agg-test-options';
|
||||
|
||||
export class MapAggTest {
|
||||
mapping_model_path!: string;
|
||||
|
||||
reflection!: ProjectReflection;
|
||||
|
||||
constructor(directory: string) {
|
||||
// eslint-disable-next-line unicorn/prefer-module
|
||||
this.mapping_model_path = path.resolve(__dirname, directory);
|
||||
this.reflection = getProjectReflection(this.mapping_model_path);
|
||||
}
|
||||
|
||||
testInterfaceAgainstPath(options: MapAggTestOptions) {
|
||||
const template = generateTemplate(this.reflection, options.ignoredTags ?? [], false, [options.name]);
|
||||
|
||||
if (typeof options.err === 'undefined') {
|
||||
expect(template.errors).to.be.deep.equal([], 'Unexpected Error!');
|
||||
} else {
|
||||
for (const error of template.errors) {
|
||||
expect(options.err).to.include(error, 'Unexpected Error!');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof options.agg !== 'undefined') {
|
||||
const expectedAggSchema = MapAggTest.buildAggregation(
|
||||
options.name,
|
||||
options.agg.fields,
|
||||
options.agg.globals,
|
||||
);
|
||||
expect(template.aggregations).to.be.deep.equal(expectedAggSchema, 'Aggregation schema not equal!');
|
||||
}
|
||||
|
||||
if (typeof options.map !== 'undefined') {
|
||||
const expectedMappingSchema = MapAggTest.buildMapping(options.name, options.map);
|
||||
expect(template.mappings).to.be.deep.equal(expectedMappingSchema, 'Mapping schema not equal!');
|
||||
}
|
||||
}
|
||||
|
||||
static buildAggregation(name: string, fields?: string[], globals?: string[]): AggregationSchema {
|
||||
const out: AggregationSchema = {
|
||||
'@all': {
|
||||
aggs: {},
|
||||
filter: {
|
||||
match_all: {},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
for (const global of globals ?? []) {
|
||||
(out['@all']! as ESNestedAggregation).aggs[global] = {
|
||||
terms: {
|
||||
field: `${global}.raw`,
|
||||
size: 1000,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof fields === 'undefined' || fields.length === 0) {
|
||||
return out;
|
||||
}
|
||||
|
||||
out[name] = {
|
||||
aggs: {},
|
||||
filter: {
|
||||
term: {
|
||||
type: name,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
for (const field of fields) {
|
||||
(out[name]! as ESNestedAggregation).aggs[field] = {
|
||||
terms: {
|
||||
field: `${field}.raw`,
|
||||
size: 1000,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static buildMapping(name: string, map: MinimalMappingDescription): ElasticsearchTemplateCollection {
|
||||
let typeNameWithoutSpaces = name.toLowerCase();
|
||||
while (typeNameWithoutSpaces.includes(' ')) {
|
||||
typeNameWithoutSpaces = typeNameWithoutSpaces.replace(' ', '_');
|
||||
}
|
||||
|
||||
const out: ElasticsearchTemplateCollection = {};
|
||||
const templateName = `template_${typeNameWithoutSpaces}`;
|
||||
out[templateName] = {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore empty object
|
||||
mappings: {},
|
||||
settings: settings,
|
||||
index_patterns: [`stapps_${typeNameWithoutSpaces}*`],
|
||||
};
|
||||
const maps = map.maps ?? {};
|
||||
maps.type = {
|
||||
type: 'text',
|
||||
};
|
||||
maps.creation_date = {
|
||||
type: 'date',
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore can be used to index
|
||||
out[templateName].mappings = {
|
||||
_source: {
|
||||
excludes: ['creation_date'],
|
||||
},
|
||||
date_detection: false,
|
||||
dynamic: 'strict',
|
||||
properties: maps,
|
||||
dynamic_templates: map.dynamicTemplates ?? [],
|
||||
};
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @date
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {PARSE_ERROR} from '../../../../lib/config/typemap.js';
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {PARSE_ERROR} from '../../../../lib/config/typemap';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {TYPE_CONFLICT} from '../../../../lib/config/typemap.js';
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {TYPE_CONFLICT} from '../../../../lib/config/typemap';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
export type FilterableEnumType = 'a' | 'b' | 'c';
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ThingType} from './types';
|
||||
|
||||
/**
|
||||
* @date
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
import {ThingType} from './types';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {MISSING_PREMAP} from '../../../../lib/config/typemap.js';
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {MISSING_PREMAP} from '../../../../lib/config/typemap';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
export interface SCISO8601DateRange {
|
||||
bar: string;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {ThingType} from './types.js';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options.js';
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../map-agg-test-options';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
|
||||
@@ -12,46 +12,22 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {readdirSync, statSync} from 'fs';
|
||||
import path from 'path';
|
||||
import {MapAggTest} from './mapping-model/map-agg-test.js';
|
||||
import {MapAggTestOptions} from './mapping-model/map-agg-test-options.js';
|
||||
import {MapAggTest} from './mapping-model/map-agg-test';
|
||||
import {MapAggTestOptions} from './mapping-model/map-agg-test-options';
|
||||
import {expandPathToFilesSync} from './common';
|
||||
|
||||
describe('ES Mapping Gen', async () => {
|
||||
const magAppInstance = new MapAggTest('mappings');
|
||||
|
||||
/**
|
||||
* Expand a path to a list of all files deeply contained in it
|
||||
*/
|
||||
// eslint-disable-next-line unicorn/consistent-function-scoping
|
||||
function expandPathToFilesSync(sourcePath: string, accept: (fileName: string) => boolean): string[] {
|
||||
const fullPath = path.resolve(sourcePath);
|
||||
const directory = statSync(fullPath);
|
||||
|
||||
return directory.isDirectory()
|
||||
? // eslint-disable-next-line unicorn/prefer-spread
|
||||
([] as string[]).concat(
|
||||
...readdirSync(fullPath).map(fragment =>
|
||||
expandPathToFilesSync(path.resolve(sourcePath, fragment), accept),
|
||||
),
|
||||
)
|
||||
: [fullPath].filter(accept);
|
||||
}
|
||||
|
||||
for (const file of expandPathToFilesSync('./test/mapping-model/mappings/', file =>
|
||||
file.endsWith('mapping-test.ts'),
|
||||
)) {
|
||||
try {
|
||||
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
||||
// eslint-disable-next-line unicorn/no-await-expression-member
|
||||
const test = (await import(file))['testConfig'] as MapAggTestOptions;
|
||||
|
||||
it(test.testName, function () {
|
||||
magAppInstance.testInterfaceAgainstPath(test);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('UNHANDLED REJECTION', (error as any).stack);
|
||||
process.exit(1);
|
||||
}
|
||||
it(test.testName, function () {
|
||||
magAppInstance.testInterfaceAgainstPath(test);
|
||||
});
|
||||
}
|
||||
})
|
||||
.timeout(20_000)
|
||||
|
||||
Reference in New Issue
Block a user