Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlog committed Dec 11, 2020
1 parent 3ff0246 commit bef91a9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,31 @@ test('adds empty composed_of correctly', () => {
expect(template.composed_of).toStrictEqual(composedOfTemplates);
});

test('adds hidden field correctly', () => {
const templateWithHiddenName = 'logs-nginx-access-abcd';

const templateWithHidden = getTemplate({
type: 'logs',
templateWithHiddenName,
packageName: 'nginx',
mappings: { properties: {} },
composedOfTemplates: [],
hidden: true,
});
expect(templateWithHidden.data_stream.hidden.toStrictEqual(true));

const templateWithoutHiddenName = 'logs-nginx-access-efgh';

const template = getTemplate({
type: 'logs',
templateWithoutHiddenName,
packageName: 'nginx',
mappings: { properties: {} },
composedOfTemplates: [],
});
expect(template.data_stream.hidden.toStrictEqual(false));
});

test('tests loading base.yml', () => {
const ymlPath = path.join(__dirname, '../../fields/tests/base.yml');
const fieldsYML = readFileSync(ymlPath, 'utf-8');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ function getBaseTemplate(
mappings: IndexTemplateMappings,
packageName: string,
composedOfTemplates: string[],
ilmPolicy?: string | undefined,
hidden?: boolean | false
): IndexTemplate {
// Meta information to identify Ingest Manager's managed templates and indices
Expand All @@ -288,7 +287,7 @@ function getBaseTemplate(
index: {
// ILM Policy must be added here, for now point to the default global ILM policy name
lifecycle: {
name: ilmPolicy ? ilmPolicy : type,
name: type,
},
// What should be our default for the compression?
codec: 'best_compression',
Expand Down

0 comments on commit bef91a9

Please sign in to comment.