mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-25 10:22:14 +00:00
feat: update tests
feat: update tests feat: update tests
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
"@types/cli-progress": "3.11.0",
|
||||
"@types/express": "4.17.17",
|
||||
"@types/morgan": "1.9.4",
|
||||
"@types/node": "14.18.43",
|
||||
"@types/node": "18.15.3",
|
||||
"@types/traverse": "0.6.32",
|
||||
"@types/uuid": "8.3.4",
|
||||
"@types/wait-on": "5.3.1",
|
||||
@@ -63,10 +63,11 @@
|
||||
"@types/chai-as-promised": "7.1.5",
|
||||
"@types/chai-spies": "1.0.3",
|
||||
"@types/cli-progress": "3.11.0",
|
||||
"@types/express": "4.17.16",
|
||||
"@types/express": "4.17.17",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/json-schema": "7.0.11",
|
||||
"@types/mocha": "10.0.1",
|
||||
"c8": "7.13.0",
|
||||
"chai": "4.3.7",
|
||||
"chai-as-promised": "7.1.1",
|
||||
"chai-spies": "1.0.0",
|
||||
@@ -74,11 +75,9 @@
|
||||
"fs-extra": "10.1.0",
|
||||
"mocha": "10.2.0",
|
||||
"nock": "13.3.1",
|
||||
"c8": "7.13.0",
|
||||
"ts-node": "10.9.1",
|
||||
"tsup": "6.7.0",
|
||||
"typedoc": "0.23.28",
|
||||
"typescript": "4.8.4"
|
||||
"typescript": "4.6.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@openstapps/core": "workspace:*"
|
||||
@@ -98,8 +97,5 @@
|
||||
"extends": [
|
||||
"@openstapps"
|
||||
]
|
||||
},
|
||||
"nyc": {
|
||||
"extends": "@openstapps/nyc-config"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@types/node": "18.15.3",
|
||||
"@types/chai": "4.3.4",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/node": "18.15.3",
|
||||
"c8": "7.13.0",
|
||||
"chai": "4.3.7",
|
||||
"mocha": "10.2.0",
|
||||
"ts-node": "10.9.1",
|
||||
"tsup": "6.7.0",
|
||||
"typescript": "4.8.4"
|
||||
"typescript": "4.6.4"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
|
||||
@@ -41,20 +41,20 @@
|
||||
"@openstapps/easy-ast": "workspace:*",
|
||||
"@openstapps/logger": "workspace:*",
|
||||
"ajv": "8.12.0",
|
||||
"re2": "1.18.0",
|
||||
"better-ajv-errors": "1.2.0",
|
||||
"commander": "10.0.0",
|
||||
"deepmerge": "4.3.1",
|
||||
"del": "6.1.1",
|
||||
"flatted": "3.2.7",
|
||||
"fs-extra": "10.1.0",
|
||||
"glob": "10.2.1",
|
||||
"glob": "10.2.6",
|
||||
"got": "12.6.0",
|
||||
"humanize-string": "3.0.0",
|
||||
"json-schema": "0.4.0",
|
||||
"mustache": "4.2.0",
|
||||
"openapi-types": "12.1.0",
|
||||
"plantuml-encoder": "1.4.0",
|
||||
"re2": "1.18.0",
|
||||
"toposort": "2.0.2",
|
||||
"ts-json-schema-generator": "1.2.0"
|
||||
},
|
||||
@@ -63,20 +63,20 @@
|
||||
"@openstapps/nyc-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@types/chai": "4.3.4",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/glob": "8.0.1",
|
||||
"@types/json-schema": "7.0.11",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/mustache": "4.2.2",
|
||||
"@types/node": "18.15.3",
|
||||
"c8": "7.13.0",
|
||||
"chai": "4.3.7",
|
||||
"mocha": "10.2.0",
|
||||
"c8": "7.13.0",
|
||||
"nock": "13.3.0",
|
||||
"tsup": "6.7.0",
|
||||
"nock": "13.3.1",
|
||||
"ts-node": "10.9.1",
|
||||
"typescript": "4.8.4"
|
||||
"tsup": "6.7.0",
|
||||
"typescript": "4.6.4"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
|
||||
@@ -46,28 +46,28 @@
|
||||
"rfdc": "1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/easy-ast": "workspace:*",
|
||||
"@openstapps/es-mapping-generator": "workspace:*",
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/logger": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@openstapps/easy-ast": "workspace:*",
|
||||
"@types/chai": "4.3.4",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/json-patch": "0.0.30",
|
||||
"@types/json-schema": "7.0.11",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/node": "18.15.3",
|
||||
"@typescript-eslint/eslint-plugin": "5.49.0",
|
||||
"@typescript-eslint/parser": "5.49.0",
|
||||
"c8": "7.13.0",
|
||||
"chai": "4.3.7",
|
||||
"conditional-type-checks": "1.0.6",
|
||||
"mocha": "10.2.0",
|
||||
"c8": "7.13.0",
|
||||
"source-map-support": "0.5.21",
|
||||
"surge": "0.23.1",
|
||||
"ts-node": "10.9.1",
|
||||
"tsup": "6.7.0",
|
||||
"typescript": "4.8.4"
|
||||
"typescript": "4.6.4"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
"dependencies": {
|
||||
"@openstapps/collection-utils": "workspace:*",
|
||||
"@openstapps/logger": "workspace:*",
|
||||
"glob": "10.2.1",
|
||||
"typescript": "4.8.4"
|
||||
"glob": "10.2.6",
|
||||
"typescript": "4.6.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@types/chai": "4.3.4",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/node": "18.15.3",
|
||||
"c8": "7.13.0",
|
||||
|
||||
@@ -28,17 +28,17 @@
|
||||
"typescript": "3.8.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@testdeck/mocha": "0.3.3",
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@types/chai": "4.3.4",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/node": "14.18.38",
|
||||
"@types/rimraf": "3.0.2",
|
||||
"c8": "7.13.0",
|
||||
"chai": "4.3.7",
|
||||
"mocha": "10.2.0",
|
||||
"c8": "7.13.0",
|
||||
"nock": "13.3.0",
|
||||
"nock": "13.3.1",
|
||||
"rimraf": "5.0.0",
|
||||
"ts-node": "10.9.1"
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
"@typescript-eslint/parser": "5.49.0",
|
||||
"ts-node": "10.9.1",
|
||||
"tsup": "6.7.0",
|
||||
"typedoc": "0.23.28",
|
||||
"typescript": "4.8.4"
|
||||
"typedoc": "0.24.7",
|
||||
"typescript": "4.6.4"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
|
||||
@@ -31,20 +31,20 @@
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
"@types/chai": "4.3.4",
|
||||
"@types/chai": "4.3.5",
|
||||
"@types/chai-as-promised": "7.1.5",
|
||||
"@types/chai-spies": "1.0.3",
|
||||
"@types/mocha": "10.0.1",
|
||||
"@types/node": "18.15.3",
|
||||
"c8": "7.13.0",
|
||||
"chai": "4.3.7",
|
||||
"chai-as-promised": "7.1.1",
|
||||
"chai-spies": "1.0.0",
|
||||
"mocha": "10.2.0",
|
||||
"c8": "7.13.0",
|
||||
"ts-node": "10.9.1",
|
||||
"tsup": "6.7.0",
|
||||
"typedoc": "0.23.28",
|
||||
"typescript": "4.8.4"
|
||||
"typedoc": "0.24.7",
|
||||
"typescript": "4.6.4"
|
||||
},
|
||||
"tsup": {
|
||||
"entry": [
|
||||
|
||||
Reference in New Issue
Block a user