fix: filter tags override inherited type tags

This commit is contained in:
Wieland Schöbl
2021-09-28 12:49:02 +00:00
parent 61b1fde0ec
commit f0401e1889
41 changed files with 218 additions and 257 deletions

View File

@@ -27,7 +27,8 @@ export interface AnyUnknown {
type: ThingType.AnyUnknown
}
export const anyUnknownTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Any or unknown should create a dynamic field',
name: ThingType.AnyUnknown,
map: {
maps: {

View File

@@ -36,7 +36,8 @@ export interface DateAndRange {
type: ThingType.Date
}
export const dateAndRangeTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Dates and date ranges should have the correct type',
name: ThingType.Date,
map: {
maps: {

View File

@@ -30,7 +30,8 @@ interface InterfaceWithDefaultGeneric<T = number> {
bar: T;
}
export const defaultGenericTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Default generics should fail',
name: ThingType.DefaultGeneric,
map: {
maps: {

View File

@@ -36,7 +36,8 @@ export interface DoubleTypeConflict {
type: ThingType.DoubleTypeConflict;
}
export const doubleTypeConflictTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Double type annotations should cause an error',
name: ThingType.DoubleTypeConflict,
map: {
maps: {

View File

@@ -40,7 +40,10 @@ enum Baz {
f = 'f',
}
export const enumTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
// Known issue: Enums only use text
// https://gitlab.com/openstapps/core-tools/-/issues/46
testName: 'Emums should work',
name: ThingType.Enum,
map: {
maps: {

View File

@@ -48,7 +48,8 @@ export interface FilterableTag {
type: ThingType.FilterableTag
}
export const filterableTagTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Filterable tag should add raw field to strings',
name: ThingType.FilterableTag,
map: {
maps: {

View File

@@ -35,7 +35,8 @@ interface InterfaceWithStringGeneric<T> {
bar: T;
}
export const genericTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Generics should work',
name: ThingType.Generics,
map: {
maps: {

View File

@@ -26,7 +26,8 @@ export interface ImpossibleUnion {
type: ThingType.ImpossibleUnion
}
export const impossibleUnionTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Impossible union should cause an error',
name: ThingType.ImpossibleUnion,
map: {
maps: {

View File

@@ -45,7 +45,8 @@ export interface DoubleTypeConflict {
type: ThingType.IncompatibleType;
}
export const incompatibleTypeTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Incompatible type annotations should cause an error and use defaults',
name: ThingType.IncompatibleType,
map: {
maps: {

View File

@@ -31,7 +31,8 @@ export interface IndexSignature {
type: ThingType.IndexSignature;
}
export const indexSignatureTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Index Signatures should work',
name: ThingType.IndexSignature,
map: {
maps: {

View File

@@ -0,0 +1,60 @@
/*
* 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/config/typemap';
import {MapAggTestOptions} from '../../MapAggTestOptions';
import {ThingType} from './types';
/**
* @date
*/
export type SCISO8601Date = string;
/**
* @indexable
*/
export interface InferredTypeFilterable {
/**
* @filterable
*/
foo: SCISO8601Date;
/**
* // no tag
*/
bar: SCISO8601Date;
type: ThingType.InferredTypeFilterable
}
export const testConfig: MapAggTestOptions = {
testName: 'filterable tags should not override inferred tags',
name: ThingType.InferredTypeFilterable,
map: {
maps: {
foo: {
type: ElasticsearchDataType.date,
fields: {
raw: {
type: ElasticsearchDataType.keyword,
}
}
},
bar: {
type: ElasticsearchDataType.date,
}
}
}
};

View File

@@ -36,7 +36,8 @@ export interface InheritTags {
type: ThingType.InheritTags;
}
export const inheritTagsTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Inherit tags tag should work',
name: ThingType.InheritTags,
map: {
maps: {

View File

@@ -38,7 +38,8 @@ interface Bar {
baz: number;
}
export const inheritedPropertyTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Inherited properties should inherit tags',
name: ThingType.InheritedProperty,
map: {
maps: {

View File

@@ -29,7 +29,8 @@ export interface InvalidTag {
type: ThingType.InvalidTag;
}
export const invalidTagTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Invalid tags should cause an error',
name: ThingType.InvalidTag,
map: {
maps: {

View File

@@ -54,7 +54,8 @@ export interface MapExplicitTypes {
type: ThingType.MapExplicitTypes;
}
export const mapExplicitTypesTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Explicit type annotations should work',
name: ThingType.MapExplicitTypes,
map: {
maps: {

View File

@@ -29,7 +29,8 @@ export interface MissingPremap {
type: ThingType.MissingPremap;
}
export const missingPremapTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Missing premap should cause an error',
name: ThingType.MissingPremap,
map: {
maps: {

View File

@@ -37,7 +37,8 @@ export interface Nested {
type: ThingType.Nested;
}
export const nestedTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Nested properties should work',
name: ThingType.Nested,
map: {
maps: {

View File

@@ -40,7 +40,8 @@ interface Buu {
intersection: string;
}
export const objectUnionTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Object union types should work',
name: ThingType.ObjectUnion,
map: {
maps: {

View File

@@ -37,7 +37,8 @@ export interface PairedTags {
type: ThingType.PairedTags;
}
export const pairedTagsTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Tags should be able to be paired',
name: ThingType.PairedTags,
map: {
maps: {

View File

@@ -31,7 +31,8 @@ export interface SensibleDefaults {
type: ThingType.SensibleDefaultType;
}
export const sensibleDefaultsTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Primitive types should have sensible defaults',
name: ThingType.SensibleDefaultType,
map: {
maps: {

View File

@@ -39,7 +39,8 @@ export interface SortableTag {
type: ThingType.SortableTag
}
export const sortableTagTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Sortable tag should work',
name: ThingType.SortableTag,
map: {
maps: {

View File

@@ -40,7 +40,8 @@ export interface TagsIgnoreCase {
type: ThingType.TagsIgnoreCase;
}
export const tagsIgnoreCaseTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Tags should ignore case',
name: ThingType.TagsIgnoreCase,
map: {
maps: {

View File

@@ -49,7 +49,8 @@ type ATextAlias = string;
*/
type AKeywordAlias = string;
export const typeAliasTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Type alias annotations should work',
name: ThingType.TypeAlias,
map: {
maps: {

View File

@@ -30,7 +30,8 @@ export interface TypeOverrides {
type: ThingType.TypeOverrides
}
export const typeOverridesTest: MapAggTestOptions = {
export const testConfig: MapAggTestOptions = {
testName: 'Premaps should support non-external types',
name: ThingType.TypeOverrides,
map: {
maps: {

View File

@@ -32,7 +32,9 @@ enum Bar {
'c'
}
export const typeQueryTest: MapAggTestOptions = {
// https://gitlab.com/openstapps/core-tools/-/issues/47
export const testConfig: MapAggTestOptions = {
testName: 'Type queries should work',
name: ThingType.TypeQuery,
map: {
maps: {

View File

@@ -43,7 +43,9 @@ type NumberWrapper = number;
type StringWrapper = string;
type StringLiteralWrapper = 'foo';
export const typeWrapperInheritanceTest: MapAggTestOptions = {
// https://gitlab.com/openstapps/core-tools/-/merge_requests/29
export const testConfig: MapAggTestOptions = {
testName: 'Wrapper types should inherit tags',
name: ThingType.TypeWrapperInheritance,
map: {
maps: {

View File

@@ -34,6 +34,7 @@ export enum ThingType {
PairedTags = 'paired tags',
FilterableTag = 'filterable tag',
AnyUnknown = 'any unknown',
InferredTypeFilterable = 'inferred type filterable',
Date = 'date',
InheritTags = 'inherit tags',
TagsIgnoreCase = 'tags ignore case',