Skip to content

Commit

Permalink
1) Updated the jest conditions to allow equal to and above 0. 2) Set …
Browse files Browse the repository at this point in the history
…default values of [PHASE_ROLLOVER_MINIMUM_AGE]: 0 in [cold,warm,delete_phase].js. 3) Set phase[numberedAttribute] <= 0 in lifecycle.js
  • Loading branch information
jkelastic committed Dec 21, 2019
1 parent 231071a commit 3d23c4e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import sinon from 'sinon';
import { findTestSubject } from '@elastic/eui/lib/test';
import {
positiveNumbersAboveZeroErrorMessage,
numberRequiredMessage,
positiveNumbersEqualAboveZeroErrorMessage,
positiveNumberRequiredMessage,
maximumAgeRequiredMessage,
maximumSizeRequiredMessage,
Expand Down Expand Up @@ -238,22 +238,14 @@ describe('edit policy', () => {
});
});
describe('warm phase', () => {
test('should show number required error when trying to save empty warm phase', () => {
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'warm');
save(rendered);
expectedErrorMessages(rendered, [numberRequiredMessage]);
});
test('should show positive number required above zero error when trying to save warm phase with 0 for after', () => {
test('should show positive number required equal to or above zero error when trying to save warm phase with 0 for after', () => {
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'warm');
setPhaseAfter(rendered, 'warm', 0);
save(rendered);
expectedErrorMessages(rendered, [positiveNumbersAboveZeroErrorMessage]);
expectedErrorMessages(rendered, [positiveNumbersEqualAboveZeroErrorMessage]);
});
test('should show positive number required error when trying to save warm phase with -1 for after', () => {
const rendered = mountWithIntl(component);
Expand Down Expand Up @@ -383,14 +375,14 @@ describe('edit policy', () => {
});
});
describe('cold phase', () => {
test('should show positive number required error when trying to save cold phase with 0 for after', () => {
test('should show positive number required error when trying to save cold phase with less than 0 for after', () => {
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'cold');
setPhaseAfter(rendered, 'cold', 0);
save(rendered);
expectedErrorMessages(rendered, [positiveNumbersAboveZeroErrorMessage]);
expectedErrorMessages(rendered, [positiveNumbersEqualAboveZeroErrorMessage]);
});
test('should show positive number required error when trying to save cold phase with -1 for after', () => {
const rendered = mountWithIntl(component);
Expand Down Expand Up @@ -464,14 +456,14 @@ describe('edit policy', () => {
});
});
describe('delete phase', () => {
test('should show positive number required error when trying to save delete phase with 0 for after', () => {
test('should show positive number required error when trying to save delete phase with less than 0 for after', () => {
const rendered = mountWithIntl(component);
noRollover(rendered);
setPolicyName(rendered, 'mypolicy');
activatePhase(rendered, 'delete');
setPhaseAfter(rendered, 'delete', 0);
save(rendered);
expectedErrorMessages(rendered, [positiveNumbersAboveZeroErrorMessage]);
expectedErrorMessages(rendered, [positiveNumbersEqualAboveZeroErrorMessage]);
});
test('should show positive number required error when trying to save delete phase with -1 for after', () => {
const rendered = mountWithIntl(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
export const defaultColdPhase = {
[PHASE_ENABLED]: false,
[PHASE_ROLLOVER_ALIAS]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: 0,
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: 'd',
[PHASE_NODE_ATTRS]: '',
[PHASE_REPLICA_COUNT]: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const defaultDeletePhase = {
[PHASE_ENABLED]: false,
[PHASE_ROLLOVER_ENABLED]: false,
[PHASE_ROLLOVER_ALIAS]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: 0,
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: 'd',
};
export const defaultEmptyDeletePhase = defaultDeletePhase;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const defaultWarmPhase = {
[PHASE_ROLLOVER_ALIAS]: '',
[PHASE_FORCE_MERGE_SEGMENTS]: '',
[PHASE_FORCE_MERGE_ENABLED]: false,
[PHASE_ROLLOVER_MINIMUM_AGE]: '',
[PHASE_ROLLOVER_MINIMUM_AGE]: 0,
[PHASE_ROLLOVER_MINIMUM_AGE_UNITS]: 'd',
[PHASE_NODE_ATTRS]: '',
[PHASE_SHRINK_ENABLED]: false,
Expand Down

0 comments on commit 3d23c4e

Please sign in to comment.