Skip to content

Commit

Permalink
Fix failing snapshort artifact tests when using KBN_ES_SNAPSHOT_USE_U…
Browse files Browse the repository at this point in the history
…NVERIFIED
  • Loading branch information
brianseeders committed Jan 27, 2020
1 parent 1df0190 commit 2f4b778
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions packages/kbn-es/src/artifact.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,22 @@ const createArchive = (params = {}) => {
const mockFetch = mock =>
fetch.mockReturnValue(Promise.resolve(new Response(JSON.stringify(mock))));

let previousSnapshotManifestValue = null;
const previousEnvVars = {};
const ENV_VARS_TO_RESET = ['ES_SNAPSHOT_MANIFEST', 'KBN_ES_SNAPSHOT_USE_UNVERIFIED'];

beforeAll(() => {
if ('ES_SNAPSHOT_MANIFEST' in process.env) {
previousSnapshotManifestValue = process.env.ES_SNAPSHOT_MANIFEST;
delete process.env.ES_SNAPSHOT_MANIFEST;
}
ENV_VARS_TO_RESET.forEach(key => {
if (key in process.env) {
previousEnvVars[key] = process.env[key];
delete process.env[key];
}
});
});

afterAll(() => {
if (previousSnapshotManifestValue !== null) {
process.env.ES_SNAPSHOT_MANIFEST = previousSnapshotManifestValue;
} else {
delete process.env.ES_SNAPSHOT_MANIFEST;
}
Object.keys(previousEnvVars).forEach(key => {
process.env[key] = previousEnvVars[key];
});
});

beforeEach(() => {
Expand Down

0 comments on commit 2f4b778

Please sign in to comment.