-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/getUserProperties' into v1
- Loading branch information
Showing
19 changed files
with
239 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
'use strict' | ||
|
||
const tap = require('tap') | ||
const nock = require('nock') | ||
|
||
const MY_AWESOME_SERVICE_PROXY_URL = 'my-awesome-service' | ||
const MICROSERVICE_GATEWAY_SERVICE_NAME = 'microservice-gateway' | ||
const { getDirectServiceProxy, getServiceProxy } = require('../index') | ||
|
||
tap.test('getDirectServiceProxy available for testing', async t => { | ||
nock.disableNetConnect() | ||
t.tearDown(() => { | ||
nock.enableNetConnect() | ||
}) | ||
|
||
const RETURN_MESSAGE = 'OK' | ||
const customProxy = getDirectServiceProxy(MY_AWESOME_SERVICE_PROXY_URL) | ||
const awesomeServiceScope = nock(`http://${MY_AWESOME_SERVICE_PROXY_URL}:80`) | ||
.get('/test-endpoint') | ||
.reply(200, { | ||
message: RETURN_MESSAGE, | ||
}) | ||
|
||
const result = await customProxy.get('/test-endpoint') | ||
|
||
t.strictSame(result.statusCode, 200) | ||
t.strictSame(result.payload.message, RETURN_MESSAGE) | ||
awesomeServiceScope.done() | ||
}) | ||
|
||
tap.test('getDirectServiceProxy accept all options', async t => { | ||
nock.disableNetConnect() | ||
t.tearDown(() => { | ||
nock.enableNetConnect() | ||
}) | ||
|
||
const RETURN_MESSAGE = 'OK' | ||
const customProxy = getDirectServiceProxy(MY_AWESOME_SERVICE_PROXY_URL, { | ||
port: 3000, | ||
}) | ||
|
||
const awesomeServiceScope = nock(`http://${MY_AWESOME_SERVICE_PROXY_URL}:3000`) | ||
.get('/test-endpoint') | ||
.reply(200, { | ||
message: RETURN_MESSAGE, | ||
}) | ||
|
||
const result = await customProxy.get('/test-endpoint') | ||
|
||
t.strictSame(result.statusCode, 200) | ||
t.strictSame(result.payload.message, RETURN_MESSAGE) | ||
awesomeServiceScope.done() | ||
}) | ||
|
||
tap.test('getServiceProxy available for testing', async t => { | ||
nock.disableNetConnect() | ||
t.tearDown(() => { | ||
nock.enableNetConnect() | ||
}) | ||
|
||
const RETURN_MESSAGE = 'OK' | ||
const customProxy = getServiceProxy(MICROSERVICE_GATEWAY_SERVICE_NAME, { port: 3000 }) | ||
const microserviceScope = nock(`http://${MICROSERVICE_GATEWAY_SERVICE_NAME}:3000`) | ||
.get('/test-endpoint') | ||
.reply(200, { | ||
message: RETURN_MESSAGE, | ||
}) | ||
|
||
|
||
const result = await customProxy.get('/test-endpoint') | ||
|
||
t.strictSame(result.statusCode, 200) | ||
t.strictSame(result.payload.message, RETURN_MESSAGE) | ||
microserviceScope.done() | ||
}) |
Oops, something went wrong.