Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Commit 0b5ef5d

Browse files
author
Chris Wiechmann
committed
Integration-Tests - Overwrite variables
1 parent a8f5110 commit 0b5ef5d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

apibuilder4elastic/test/trafficMonitorAPI/asAdmin/jms/test_search_jms_AsAdmin.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const getDate = require('../../../util');
44
const path = require('path');
55
const fs = require('fs');
66
const nock = require('nock');
7-
const envLoader = require('dotenv');
7+
const dotenv = require('dotenv');
88

99
describe('Endpoints', function () {
1010
this.timeout(30000);
@@ -29,8 +29,10 @@ describe('Endpoints', function () {
2929
before(() => {
3030
return new Promise(function(resolve, reject){
3131
const envFilePath = path.join(__dirname, '../../../.env');
32-
if (fs.existsSync(envFilePath)) {
33-
envLoader.config({ path: envFilePath });
32+
// Make sure the existing environment variables are overwritten (https://github.com/motdotla/dotenv#what-happens-to-environment-variables-that-were-already-set)
33+
const envConfig = dotenv.parse(fs.readFileSync(envFilePath));
34+
for (const k in envConfig) {
35+
process.env[k] = envConfig[k];
3436
}
3537
server = startApiBuilder();
3638
server.apibuilder.config.testElasticIndex = indexName;

apibuilder4elastic/test/trafficMonitorAPI/asAdmin/payload/test_payload.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { startApiBuilder, stopApiBuilder, requestAsync, sendToElasticsearch, getR
33
const path = require('path');
44
const fs = require('fs');
55
const nock = require('nock');
6-
const envLoader = require('dotenv');
6+
const dotenv = require('dotenv');
77

88
describe('Payload', function () {
99
this.timeout(30000);
@@ -29,8 +29,10 @@ describe('Payload', function () {
2929
before(() => {
3030
return new Promise(function(resolve, reject){
3131
const envFilePath = path.join(__dirname, '../../../.env');
32-
if (fs.existsSync(envFilePath)) {
33-
envLoader.config({ path: envFilePath });
32+
// Make sure the existing environment variables are overwritten (https://github.com/motdotla/dotenv#what-happens-to-environment-variables-that-were-already-set)
33+
const envConfig = dotenv.parse(fs.readFileSync(envFilePath));
34+
for (const k in envConfig) {
35+
process.env[k] = envConfig[k];
3436
}
3537
process.env.PAYLOAD_FOLDER = payloadFolder;
3638
// Should be limited to bytes => This is a large payload, that should be limited.

0 commit comments

Comments
 (0)