feat: tests

This commit is contained in:
2023-04-21 12:08:35 +02:00
parent 8cb9285462
commit d8c79256c9
140 changed files with 2100 additions and 2693 deletions

View File

@@ -13,11 +13,11 @@
"author": "Thea Schöbl <dev@theaninova.de>",
"scripts": {
"build": "rimraf lib && tsc",
"format": "prettier .",
"format:fix": "prettier --write .",
"format": "prettier . --ignore-path ../../.gitignore",
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
"lint": "eslint -c .eslintrc --ignore-path .eslintignore --ext .ts src/ test/",
"lint:fix": "eslint --fix -c .eslintrc --ignore-path .eslintignore --ext .ts src/ test/",
"test": "mocha --require ts-node/register test/*.spec.ts"
"test": "c8 mocha"
},
"dependencies": {
"@elastic/elasticsearch": "8.4.0",
@@ -38,9 +38,10 @@
"@types/rimraf": "3.0.2",
"chai": "4.3.7",
"mocha": "10.2.0",
"c8": "7.13.0",
"nock": "13.3.0",
"rimraf": "5.0.0",
"ts-node": "10.9.1",
"rimraf": "5.0.0"
},
"prettier": "@openstapps/prettier-config"
}

View File

@@ -17,9 +17,9 @@ import {mkdirSync, readFileSync, writeFileSync} from 'fs';
import got from 'got';
import path from 'path';
import {exit} from 'process';
import {generateTemplate} from './mapping.js';
import {getProjectReflection} from './project-reflection.js';
import {ElasticsearchTemplateCollection} from './types/mapping.js';
import {generateTemplate} from './mapping';
import {getProjectReflection} from './project-reflection';
import {ElasticsearchTemplateCollection} from './types/mapping';
// handle unhandled promise rejections
process.on('unhandledRejection', async (reason: unknown) => {

View File

@@ -13,7 +13,7 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {MappingFloatNumberProperty} from '@elastic/elasticsearch/lib/api/types';
import {ElasticsearchTypemap} from '../types/mapping.js';
import {ElasticsearchTypemap} from '../types/mapping';
export const PARSE_ERROR = 'PARSE_ERROR' as MappingFloatNumberProperty['type'];
export const MISSING_PREMAP = 'MISSING_PREMAP' as MappingFloatNumberProperty['type'];

View File

@@ -1,6 +1,10 @@
export * from './mapping'
export * from './project-reflection'
export * from './config/premap'
export * from './config/fieldmap'
export * from './config/settings'
export * from './config/typemap'
export * from './mapping';
export * from './project-reflection';
export * from './config/premap';
export * from './config/fieldmap';
export * from './config/settings';
export * from './config/typemap';
export * from './types/mapping';
export * from './types/aggregation';

View File

@@ -33,13 +33,13 @@ import {
TypeParameterType,
UnionType,
} from 'typedoc/dist/lib/models';
import {fieldmap, filterableMap, filterableTagName} from './config/fieldmap.js';
import {premaps} from './config/premap.js';
import {settings} from './config/settings.js';
import {dynamicTypes, isTagType, MISSING_PREMAP, PARSE_ERROR, TYPE_CONFLICT, typemap} from './config/typemap.js';
import {AggregationSchema, ESNestedAggregation} from './types/aggregation.js';
import {fieldmap, filterableMap, filterableTagName} from './config/fieldmap';
import {premaps} from './config/premap';
import {settings} from './config/settings';
import {dynamicTypes, isTagType, MISSING_PREMAP, PARSE_ERROR, TYPE_CONFLICT, typemap} from './config/typemap';
import {AggregationSchema, ESNestedAggregation} from './types/aggregation';
import {ElasticsearchTemplateCollection,
MappingGenTemplate} from './types/mapping.js';
MappingGenTemplate} from './types/mapping';
import * as console from 'console';
let dynamicTemplates: Record<string, MappingDynamicTemplate>[] = [];

View File

@@ -12,7 +12,6 @@
* 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 {Logger} from '@openstapps/logger';
import {readdirSync, statSync} from 'fs';
import path from 'path';
import {MapAggTest} from './mapping-model/map-agg-test.js';
@@ -48,8 +47,8 @@ describe('ES Aggregation Gen', async () => {
it(test.testName, function () {
magAppInstance.testInterfaceAgainstPath(test);
});
} catch (error: any) {
await Logger.error('UNHANDLED REJECTION', error.stack);
} catch (error) {
console.error('UNHANDLED REJECTION', (error as any).stack);
process.exit(1);
}
}

View File

@@ -12,7 +12,6 @@
* 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';

View File

@@ -54,7 +54,7 @@ export const testConfig: MapAggTestOptions = {
dynamic: 'strict',
properties: {
baz: {
type: 'float',
type: ElasticsearchDataType.float,
},
},
},

View File

@@ -12,7 +12,6 @@
* 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 {Logger} from '@openstapps/logger';
import {readdirSync, statSync} from 'fs';
import path from 'path';
import {MapAggTest} from './mapping-model/map-agg-test.js';
@@ -49,8 +48,8 @@ describe('ES Mapping Gen', async () => {
it(test.testName, function () {
magAppInstance.testInterfaceAgainstPath(test);
});
} catch (error: any) {
await Logger.error('UNHANDLED REJECTION', error.stack);
} catch (error) {
console.error('UNHANDLED REJECTION', (error as any).stack);
process.exit(1);
}
}