mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +00:00
feat: add support for @inheritTags
This commit is contained in:
committed by
Wieland Schöbl
parent
97f6c42407
commit
485430b7f2
57
test/mapping-model/mappings/src/inherit-tags.ts
Normal file
57
test/mapping-model/mappings/src/inherit-tags.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
// tslint:disable
|
||||
/*
|
||||
* 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 {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ThingType} from './types';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface InheritTags {
|
||||
/**
|
||||
* @inheritTags inherit tags::bar.baz
|
||||
*/
|
||||
foo: number,
|
||||
|
||||
bar: {
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
baz: number
|
||||
}
|
||||
|
||||
type: ThingType.InheritTags;
|
||||
}
|
||||
|
||||
export const inheritTagsTest: MapAggTestOptions = {
|
||||
name: ThingType.InheritTags,
|
||||
map: {
|
||||
maps: {
|
||||
foo: {
|
||||
type: ElasticsearchDataType.float
|
||||
},
|
||||
bar: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
49
test/mapping-model/mappings/src/tags-ignore-case.ts
Normal file
49
test/mapping-model/mappings/src/tags-ignore-case.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import {ThingType} from './types';
|
||||
import {MapAggTestOptions} from '../../MapAggTestOptions';
|
||||
import {ElasticsearchDataType} from '../../../../src/mappings/definitions/typemap';
|
||||
|
||||
/**
|
||||
* @indexable
|
||||
*/
|
||||
export interface TagsIgnoreCase {
|
||||
/**
|
||||
* @inheritTags inherit tags::bar.baz
|
||||
*/
|
||||
camelCase: number,
|
||||
|
||||
/**
|
||||
* @inherittags inherit tags::bar.baz
|
||||
*/
|
||||
lowerCase: number,
|
||||
|
||||
bar: {
|
||||
/**
|
||||
* @float
|
||||
*/
|
||||
baz: number
|
||||
}
|
||||
|
||||
type: ThingType.TagsIgnoreCase;
|
||||
}
|
||||
|
||||
export const tagsIgnoreCaseTest: MapAggTestOptions = {
|
||||
name: ThingType.TagsIgnoreCase,
|
||||
map: {
|
||||
maps: {
|
||||
camelCase: {
|
||||
type: ElasticsearchDataType.float
|
||||
},
|
||||
lowerCase: {
|
||||
type: ElasticsearchDataType.float
|
||||
},
|
||||
bar: {
|
||||
dynamic: 'strict',
|
||||
properties: {
|
||||
baz: {
|
||||
type: ElasticsearchDataType.float
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -35,4 +35,6 @@ export enum ThingType {
|
||||
PairedTags = 'paired tags',
|
||||
FilterableTag = 'filterable tag',
|
||||
AnyUnknown = 'any unknown',
|
||||
InheritTags = 'inherit tags',
|
||||
TagsIgnoreCase = 'tags ignore case',
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// tslint:disable
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -16,6 +15,7 @@
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {slow, suite, test, timeout} from 'mocha-typescript';
|
||||
import {MapAggTest} from './mapping-model/MapAggTest';
|
||||
import {inheritTagsTest} from './mapping-model/mappings/src/inherit-tags';
|
||||
import {mapExplicitTypesTest} from './mapping-model/mappings/src/map-explicit-types';
|
||||
import {doubleTypeConflictTest} from './mapping-model/mappings/src/double-type-conflict';
|
||||
import {incompatibleTypeTest} from './mapping-model/mappings/src/incompatible-type';
|
||||
@@ -34,6 +34,7 @@ import {inheritedPropertyTest} from './mapping-model/mappings/src/inherited-prop
|
||||
import {pairedTagsTest} from './mapping-model/mappings/src/paired-tags';
|
||||
import {filterableTagTest} from './mapping-model/mappings/src/filterable-tag';
|
||||
import {anyUnknownTest} from './mapping-model/mappings/src/any-unknown';
|
||||
import {tagsIgnoreCaseTest} from './mapping-model/mappings/src/tags-ignore-case';
|
||||
|
||||
process.on('unhandledRejection', (error: unknown) => {
|
||||
if (error instanceof Error) {
|
||||
@@ -66,6 +67,11 @@ export class MappingSpec {
|
||||
magAppInstance.testInterfaceAgainstPath(inheritedPropertyTest);
|
||||
}
|
||||
|
||||
@test
|
||||
async 'Tags should ignore case'() {
|
||||
magAppInstance.testInterfaceAgainstPath(tagsIgnoreCaseTest);
|
||||
}
|
||||
|
||||
@test
|
||||
async 'Emums should work'() {
|
||||
// Known issue: Enums only use text
|
||||
@@ -74,7 +80,7 @@ export class MappingSpec {
|
||||
}
|
||||
|
||||
@test
|
||||
'Sortable tag should work'() {
|
||||
async 'Sortable tag should work'() {
|
||||
magAppInstance.testInterfaceAgainstPath(sortableTagTest);
|
||||
}
|
||||
|
||||
@@ -85,6 +91,11 @@ export class MappingSpec {
|
||||
this.testInterfaceAgainstPath(typeWrapperInheritanceTest);
|
||||
}*/
|
||||
|
||||
@test
|
||||
async 'Inherit tags tag should work'() {
|
||||
magAppInstance.testInterfaceAgainstPath(inheritTagsTest);
|
||||
}
|
||||
|
||||
@test
|
||||
async 'Object union types should work'() {
|
||||
magAppInstance.testInterfaceAgainstPath(objectUnionTest);
|
||||
|
||||
@@ -25,7 +25,7 @@ process.on('unhandledRejection', (error: unknown) => {
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
@suite(timeout(20000), slow(10000))
|
||||
@suite(timeout(40000), slow(10000))
|
||||
export class SchemaSpec {
|
||||
@test
|
||||
async getSchema() {
|
||||
|
||||
@@ -36,7 +36,7 @@ const fooInstance: Foo = {
|
||||
type: 'Foo',
|
||||
};
|
||||
|
||||
@suite(timeout(15000), slow(5000))
|
||||
@suite(timeout(40000), slow(5000))
|
||||
export class SchemaSpec {
|
||||
static converter: Converter;
|
||||
static schema: Schema;
|
||||
|
||||
Reference in New Issue
Block a user