Skip to content

Commit

Permalink
fix: unit test
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Oct 18, 2023
1 parent 7c9b7e0 commit ddecbcb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ describe('#importSavedObjectsFromStream', () => {
expect(validateReferences).toHaveBeenCalledWith(
collectedObjects,
savedObjectsClient,
namespace
namespace,
undefined,
undefined
);
});

Expand Down
7 changes: 6 additions & 1 deletion src/core/server/saved_objects/import/validate_references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ export async function getNonExistingReferenceAsKeys(
return [];
}

const fields = ['id'];
if (workspaces?.length) {
fields.push('workspaces');
}

// Fetch references to see if they exist
const bulkGetOpts = Array.from(collector.values()).map((obj) => ({
...obj,
fields: ['id', 'workspaces'],
fields,
}));
const bulkGetResponse = await savedObjectsClient.bulkGet(bulkGetOpts, { namespace });

Expand Down

0 comments on commit ddecbcb

Please sign in to comment.