mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
(cherry picked from commit 0600c30be4
)
Co-authored-by: Mark Hopkin <mark.hopkin@elastic.co>
This commit is contained in:
parent
3d0a7cacf0
commit
d5f112c325
2 changed files with 27 additions and 1 deletions
|
@ -372,6 +372,32 @@ describe('When using EPM `get` services', () => {
|
|||
|
||||
expect(MockRegistry.getRegistryPackage).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
// when calling the get package endpoint without a package version we
|
||||
// were previously incorrectly getting the info from archive
|
||||
it('avoids loading archive when skipArchive = true and no version supplied', async () => {
|
||||
const soClient = savedObjectsClientMock.create();
|
||||
soClient.get.mockRejectedValue(SavedObjectsErrorHelpers.createGenericNotFoundError());
|
||||
MockRegistry.fetchInfo.mockResolvedValue({
|
||||
name: 'my-package',
|
||||
version: '1.0.0',
|
||||
assets: [],
|
||||
} as unknown as RegistryPackage);
|
||||
|
||||
await expect(
|
||||
getPackageInfo({
|
||||
savedObjectsClient: soClient,
|
||||
pkgName: 'my-package',
|
||||
pkgVersion: '',
|
||||
skipArchive: true,
|
||||
})
|
||||
).resolves.toMatchObject({
|
||||
latestVersion: '1.0.0',
|
||||
status: 'not_installed',
|
||||
});
|
||||
|
||||
expect(MockRegistry.getRegistryPackage).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -155,7 +155,7 @@ export async function getPackageInfo({
|
|||
// otherwise build it from the archive
|
||||
let paths: string[];
|
||||
let packageInfo: RegistryPackage | ArchivePackage | undefined = skipArchive
|
||||
? await Registry.fetchInfo(pkgName, pkgVersion).catch(() => undefined)
|
||||
? await Registry.fetchInfo(pkgName, resolvedPkgVersion).catch(() => undefined)
|
||||
: undefined;
|
||||
|
||||
if (packageInfo) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue