Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Aug 3, 2018
1 parent 38297b0 commit c662cc4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ class MockCollectorSet {
async bulkFetch() {
return this.mockCollectors.map(({ fetch }) => fetch());
}
bulkFormat(data) {
return data.reduce((accum, collectedData) => {
if (collectedData) {
const collector = this.mockCollectors[0];
const formatter = collector.formatForBulkUpload || (result => ([
{ type: collector.type, payload: result }
]));
accum.push(formatter(collectedData.result));
}
return accum;
}, []);
}
}

describe('BulkUploader', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { get, set, flatten, uniq } from 'lodash';
import { get, set, flatten, uniq, compact } from 'lodash';
import { callClusterFactory } from '../../../xpack_main';
import {
LOGGING_TAG,
Expand Down Expand Up @@ -149,7 +149,9 @@ export class BulkUploader {
* Non-legacy transformation is done in CollectorSet.toApiStats
*/
static toBulkUploadFormat(uploadData, collectorSet) {
return flatten(BulkUploader.deepMergeUploadData(uploadData, collectorSet));
if (compact(uploadData).length > 0) {
return flatten(BulkUploader.deepMergeUploadData(uploadData, collectorSet));
}
}

static checkPayloadTypesUnique(payload) {
Expand Down

0 comments on commit c662cc4

Please sign in to comment.