Skip to content

Commit

Permalink
ensure correct ordered creation in both tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Apr 30, 2020
1 parent 471fe08 commit 43b31dc
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ export default function({ getService }: FtrProviderContext) {
it('should support sorting by event end', async () => {
const id = uuid.v4();

const expectedEvents: IEvent[] = [];
for (let index = 0; index < 6; index++) {
const event = fakeEvent(id);
await logTestEvent(id, event);
expectedEvents.push(event);
}
const expectedEvents = await logFakeEvents(id, 6);

await retry.try(async () => {
const {
Expand All @@ -109,8 +104,7 @@ export default function({ getService }: FtrProviderContext) {
const start = new Date().toISOString();

// write the documents that we should be found in the date range searches
const expectedEvents = times(6, () => fakeEvent(id));
await Promise.all(expectedEvents.map(event => logTestEvent(id, event)));
const expectedEvents = await logFakeEvents(id, 6);

// get the end time for the date range search
const end = new Date().toISOString();
Expand Down Expand Up @@ -215,4 +209,14 @@ export default function({ getService }: FtrProviderContext) {
overrides
);
}

async function logFakeEvents(savedObjectId: string, eventsToLog: number): Promise<IEvent[]> {
const expectedEvents: IEvent[] = [];
for (let index = 0; index < eventsToLog; index++) {
const event = fakeEvent(savedObjectId);
await logTestEvent(savedObjectId, event);
expectedEvents.push(event);
}
return expectedEvents;
}
}

0 comments on commit 43b31dc

Please sign in to comment.