Skip to content

Commit

Permalink
fixed test broken by merge
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Aug 19, 2020
1 parent 76ab6c0 commit 3bff869
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
7 changes: 3 additions & 4 deletions src/core/server/saved_objects/service/lib/repository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ describe('SavedObjectsRepository', () => {
if_primary_term: mockVersionProps._primary_term,
};

expectClientCallArgsAction([obj1WithSeq, obj2], { method: 'index' });
expectClusterCallArgsAction([obj1WithSeq, obj2], { method: 'index' });
});

it(`should use the ES create method if ID is defined and overwrite=false`, async () => {
Expand Down Expand Up @@ -1489,9 +1489,8 @@ describe('SavedObjectsRepository', () => {

it(`should use the ES index with version if ID and version are defined and overwrite=true`, async () => {
await createSuccess(type, attributes, { id, overwrite: true, version: mockVersion });
expect(client.index).toHaveBeenCalled();

expect(client.index.mock.calls[0][0]).toMatchObject({
expectClusterCalls('index');
expectClusterCallArgs({
if_seq_no: mockVersionProps._seq_no,
if_primary_term: mockVersionProps._primary_term,
});
Expand Down
32 changes: 16 additions & 16 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ export class SavedObjectsRepository {
injectedConstructor: any = SavedObjectsRepository
): ISavedObjectsRepository {
const mappings = migrator.getActiveMappings();
const allTypes = typeRegistry.getAllTypes().map(t => t.name);
const allTypes = typeRegistry.getAllTypes().map((t) => t.name);
const serializer = new SavedObjectsSerializer(typeRegistry);
const visibleTypes = allTypes.filter(type => !typeRegistry.isHidden(type));
const visibleTypes = allTypes.filter((type) => !typeRegistry.isHidden(type));

const missingTypeMappings = includedHiddenTypes.filter(type => !allTypes.includes(type));
const missingTypeMappings = includedHiddenTypes.filter((type) => !allTypes.includes(type));
if (missingTypeMappings.length > 0) {
throw new Error(
`Missing mappings for saved objects types: '${missingTypeMappings.join(', ')}'`
Expand Down Expand Up @@ -287,7 +287,7 @@ export class SavedObjectsRepository {
const time = this._getCurrentTime();

let bulkGetRequestIndexCounter = 0;
const expectedResults: Either[] = objects.map(object => {
const expectedResults: Either[] = objects.map((object) => {
if (!this._allowedTypes.includes(object.type)) {
return {
tag: 'Left' as 'Left',
Expand Down Expand Up @@ -334,7 +334,7 @@ export class SavedObjectsRepository {

let bulkRequestIndexCounter = 0;
const bulkCreateParams: object[] = [];
const expectedBulkResults: Either[] = expectedResults.map(expectedBulkGetResult => {
const expectedBulkResults: Either[] = expectedResults.map((expectedBulkGetResult) => {
if (isLeft(expectedBulkGetResult)) {
return expectedBulkGetResult;
}
Expand Down Expand Up @@ -412,7 +412,7 @@ export class SavedObjectsRepository {
: undefined;

return {
saved_objects: expectedBulkResults.map(expectedResult => {
saved_objects: expectedBulkResults.map((expectedResult) => {
if (isLeft(expectedResult)) {
return expectedResult.error as any;
}
Expand Down Expand Up @@ -464,7 +464,7 @@ export class SavedObjectsRepository {
preflightResult = await this.preflightCheckIncludesNamespace(type, id, namespace);
const existingNamespaces = getSavedObjectNamespaces(undefined, preflightResult);
const remainingNamespaces = existingNamespaces?.filter(
x => x !== getNamespaceString(namespace)
(x) => x !== getNamespaceString(namespace)
);

if (remainingNamespaces?.length) {
Expand Down Expand Up @@ -541,7 +541,7 @@ export class SavedObjectsRepository {

const { refresh = DEFAULT_REFRESH_SETTING } = options;
const allTypes = Object.keys(getRootPropertiesObjects(this._mappings));
const typesToUpdate = allTypes.filter(type => !this._registry.isNamespaceAgnostic(type));
const typesToUpdate = allTypes.filter((type) => !this._registry.isNamespaceAgnostic(type));

const updateOptions = {
index: this.getIndicesForTypes(typesToUpdate),
Expand Down Expand Up @@ -612,7 +612,7 @@ export class SavedObjectsRepository {
}

const types = Array.isArray(type) ? type : [type];
const allowedTypes = types.filter(t => this._allowedTypes.includes(t));
const allowedTypes = types.filter((t) => this._allowedTypes.includes(t));
if (allowedTypes.length === 0) {
return {
page,
Expand Down Expand Up @@ -719,7 +719,7 @@ export class SavedObjectsRepository {
}

let bulkGetRequestIndexCounter = 0;
const expectedBulkGetResults: Either[] = objects.map(object => {
const expectedBulkGetResults: Either[] = objects.map((object) => {
const { type, id, fields } = object;

if (!this._allowedTypes.includes(type)) {
Expand Down Expand Up @@ -761,7 +761,7 @@ export class SavedObjectsRepository {
: undefined;

return {
saved_objects: expectedBulkGetResults.map(expectedResult => {
saved_objects: expectedBulkGetResults.map((expectedResult) => {
if (isLeft(expectedResult)) {
return expectedResult.error as any;
}
Expand Down Expand Up @@ -1014,7 +1014,7 @@ export class SavedObjectsRepository {
const preflightResult = await this.preflightCheckIncludesNamespace(type, id, namespace);
const existingNamespaces = getSavedObjectNamespaces(undefined, preflightResult);
// if there are somehow no existing namespaces, allow the operation to proceed and delete this saved object
const remainingNamespaces = existingNamespaces?.filter(x => !namespaces.includes(x));
const remainingNamespaces = existingNamespaces?.filter((x) => !namespaces.includes(x));

if (remainingNamespaces?.length) {
// if there is 1 or more namespace remaining, update the saved object
Expand Down Expand Up @@ -1090,7 +1090,7 @@ export class SavedObjectsRepository {
const { namespace } = options;

let bulkGetRequestIndexCounter = 0;
const expectedBulkGetResults: Either[] = objects.map(object => {
const expectedBulkGetResults: Either[] = objects.map((object) => {
const { type, id } = object;

if (!this._allowedTypes.includes(type)) {
Expand Down Expand Up @@ -1146,7 +1146,7 @@ export class SavedObjectsRepository {
let bulkUpdateRequestIndexCounter = 0;
const bulkUpdateParams: object[] = [];
const expectedBulkUpdateResults: Either[] = expectedBulkGetResults.map(
expectedBulkGetResult => {
(expectedBulkGetResult) => {
if (isLeft(expectedBulkGetResult)) {
return expectedBulkGetResult;
}
Expand Down Expand Up @@ -1211,7 +1211,7 @@ export class SavedObjectsRepository {
: {};

return {
saved_objects: expectedBulkUpdateResults.map(expectedResult => {
saved_objects: expectedBulkUpdateResults.map((expectedResult) => {
if (isLeft(expectedResult)) {
return expectedResult.error as any;
}
Expand Down Expand Up @@ -1364,7 +1364,7 @@ export class SavedObjectsRepository {
* @param types The types whose indices should be retrieved
*/
private getIndicesForTypes(types: string[]) {
return unique(types.map(t => this.getIndexForType(t)));
return unique(types.map((t) => this.getIndexForType(t)));
}

private _getCurrentTime() {
Expand Down

0 comments on commit 3bff869

Please sign in to comment.