mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Co-authored-by: Brian Seeders <brian.seeders@elastic.co>
This commit is contained in:
parent
777d7e646d
commit
17b76310c7
2 changed files with 34 additions and 8 deletions
|
@ -69,6 +69,18 @@ beforeEach(() => {
|
|||
valid: {
|
||||
archives: [createArchive({ license: 'oss' }), createArchive({ license: 'default' })],
|
||||
},
|
||||
invalidArch: {
|
||||
archives: [
|
||||
createArchive({ license: 'oss', architecture: 'invalid_arch' }),
|
||||
createArchive({ license: 'default', architecture: 'invalid_arch' }),
|
||||
],
|
||||
},
|
||||
differentVersion: {
|
||||
archives: [
|
||||
createArchive({ license: 'oss', version: 'another-version' }),
|
||||
createArchive({ license: 'default', version: 'another-version' }),
|
||||
],
|
||||
},
|
||||
multipleArch: {
|
||||
archives: [
|
||||
createArchive({ architecture: 'fake_arch', license: 'oss' }),
|
||||
|
@ -116,8 +128,14 @@ describe('Artifact', () => {
|
|||
artifactTest('INVALID_LICENSE', 'default')
|
||||
);
|
||||
|
||||
it('should return an artifact even if the version does not match', async () => {
|
||||
mockFetch(MOCKS.differentVersion);
|
||||
artifactTest('default', 'default');
|
||||
});
|
||||
|
||||
it('should throw when an artifact cannot be found in the manifest for the specified parameters', async () => {
|
||||
await expect(Artifact.getSnapshot('default', 'INVALID_VERSION', log)).rejects.toThrow(
|
||||
mockFetch(MOCKS.invalidArch);
|
||||
await expect(Artifact.getSnapshot('default', MOCK_VERSION, log)).rejects.toThrow(
|
||||
"couldn't find an artifact"
|
||||
);
|
||||
});
|
||||
|
@ -144,8 +162,14 @@ describe('Artifact', () => {
|
|||
artifactTest('INVALID_LICENSE', 'default', 2)
|
||||
);
|
||||
|
||||
it('should return an artifact even if the version does not match', async () => {
|
||||
mockFetch(MOCKS.differentVersion);
|
||||
artifactTest('default', 'default', 2);
|
||||
});
|
||||
|
||||
it('should throw when an artifact cannot be found in the manifest for the specified parameters', async () => {
|
||||
await expect(Artifact.getSnapshot('default', 'INVALID_VERSION', log)).rejects.toThrow(
|
||||
mockFetch(MOCKS.invalidArch);
|
||||
await expect(Artifact.getSnapshot('default', MOCK_VERSION, log)).rejects.toThrow(
|
||||
"couldn't find an artifact"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -156,16 +156,18 @@ async function getArtifactSpecForSnapshot(
|
|||
const arch = process.arch === 'arm64' ? 'aarch64' : 'x86_64';
|
||||
|
||||
const archive = manifest.archives.find(
|
||||
(a) =>
|
||||
a.version === desiredVersion &&
|
||||
a.platform === platform &&
|
||||
a.license === desiredLicense &&
|
||||
a.architecture === arch
|
||||
(a) => a.platform === platform && a.license === desiredLicense && a.architecture === arch
|
||||
);
|
||||
|
||||
if (!archive) {
|
||||
throw createCliError(
|
||||
`Snapshots for ${desiredVersion} are available, but couldn't find an artifact in the manifest for [${desiredVersion}, ${desiredLicense}, ${platform}]`
|
||||
`Snapshots are available, but couldn't find an artifact in the manifest for [${desiredLicense}, ${platform}, ${arch}]`
|
||||
);
|
||||
}
|
||||
|
||||
if (archive.version !== desiredVersion) {
|
||||
log.warning(
|
||||
`Snapshot found, but version does not match Kibana. Kibana: ${desiredVersion}, Snapshot: ${archive.version}`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue