Skip to content

Commit

Permalink
feat: default configuration input
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Jun 21, 2019
1 parent cad6188 commit e253caf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bootstrap.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require('./dist/index').bootstrap({});
require('./dist/index').bootstrap();
6 changes: 5 additions & 1 deletion src/routines/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ type ConfigurationType = {|
+environmentVariableNamespace: string
|};

const defaultConfigurationInput = {
environmentVariableNamespace: undefined
};

const log = Logger.child({
namespace: 'bootstrap'
});
Expand All @@ -43,7 +47,7 @@ const createConfiguration = (configurationInput: ConfigurationInputType): Config
};
};

export default (configurationInput: ConfigurationInputType) => {
export default (configurationInput: ConfigurationInputType = defaultConfigurationInput) => {
const configuration = createConfiguration(configurationInput);

global.GLOBAL_AGENT = global.GLOBAL_AGENT || createGlobalAgentGlobal();
Expand Down
26 changes: 13 additions & 13 deletions test/global-agent/routines/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const createHttpServer = async () => {
};

test('proxies HTTP request', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -165,7 +165,7 @@ test('proxies HTTP request', async (t) => {
});

test('proxies HTTPS request', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -179,7 +179,7 @@ test('proxies HTTPS request', async (t) => {
});

test('does not produce unhandled rejection when cannot connect to proxy', async (t) => {
bootstrap({});
bootstrap();

const port = await getNextPort();

Expand All @@ -189,7 +189,7 @@ test('does not produce unhandled rejection when cannot connect to proxy', async
});

test('proxies HTTPS request with dedicated proxy', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -203,7 +203,7 @@ test('proxies HTTPS request with dedicated proxy', async (t) => {
});

test('ignores dedicated HTTPS proxy for HTTP urls', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -218,7 +218,7 @@ test('ignores dedicated HTTPS proxy for HTTP urls', async (t) => {
});

test('forwards requests matching NO_PROXY', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();
const httpServer = await createHttpServer();
Expand All @@ -234,7 +234,7 @@ test('forwards requests matching NO_PROXY', async (t) => {
});

test('proxies HTTP request (using http.get(host))', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -250,7 +250,7 @@ test('proxies HTTP request (using http.get(host))', async (t) => {
});

test('proxies HTTP request (using got)', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -262,7 +262,7 @@ test('proxies HTTP request (using got)', async (t) => {
});

test('proxies HTTPS request (using got)', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -274,7 +274,7 @@ test('proxies HTTPS request (using got)', async (t) => {
});

test('proxies HTTP request (using axios)', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -286,7 +286,7 @@ test('proxies HTTP request (using axios)', async (t) => {
});

test('proxies HTTPS request (using axios)', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -298,7 +298,7 @@ test('proxies HTTPS request (using axios)', async (t) => {
});

test('proxies HTTP request (using request)', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand All @@ -316,7 +316,7 @@ test('proxies HTTP request (using request)', async (t) => {
});

test('proxies HTTPS request (using request)', async (t) => {
bootstrap({});
bootstrap();

const proxyServer = await createProxyServer();

Expand Down

0 comments on commit e253caf

Please sign in to comment.