@autofleet/node-common 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/settings/index.js +1 -1
- package/settings/index.test.js +8 -8
package/package.json
CHANGED
package/settings/index.js
CHANGED
|
@@ -8,7 +8,7 @@ require('dotenv').config();
|
|
|
8
8
|
const fiveMinutes = 60 * 5;
|
|
9
9
|
|
|
10
10
|
const findUrl = serviceUrl => serviceUrl ||
|
|
11
|
-
|
|
11
|
+
(process.env.SETTING_MS_SERVICE_HOST && process.env.SETTING_MS_SERVICE_HOST.length > 0 ? `http://${process.env.SETTING_MS_SERVICE_HOST}/` : undefined) ||
|
|
12
12
|
(process.env.NODE_ENV !== 'test' ? 'http://setting-ms.autofleet.io/' : 'http://localhost:9999/');
|
|
13
13
|
|
|
14
14
|
module.exports = class SettingsManager {
|
package/settings/index.test.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const nock = require('nock');
|
|
2
2
|
const Settings = require('./index');
|
|
3
3
|
|
|
4
|
-
const serviceUrl = '
|
|
4
|
+
const serviceUrl = 'localhost:8085';
|
|
5
5
|
|
|
6
|
-
const mockSetting = (key, value, labels, response = 200) => nock(serviceUrl)
|
|
6
|
+
const mockSetting = (key, value, labels, response = 200) => nock(`http://${serviceUrl}/`)
|
|
7
7
|
.get(`/api/v1/settings/get-setting/${key}`)
|
|
8
8
|
.query(labels ? { labels } : undefined)
|
|
9
9
|
.reply(response, { value });
|
|
@@ -11,7 +11,7 @@ const mockSetting = (key, value, labels, response = 200) => nock(serviceUrl)
|
|
|
11
11
|
describe('Settings', () => {
|
|
12
12
|
it('Throws exeption if there is no defualt value', async () => {
|
|
13
13
|
const settings = new Settings({
|
|
14
|
-
serviceUrl
|
|
14
|
+
serviceUrl: `http://${serviceUrl}/`,
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
expect(settings.get('key1'))
|
|
@@ -32,7 +32,7 @@ describe('Settings', () => {
|
|
|
32
32
|
it('Get a key from server', async () => {
|
|
33
33
|
const m = mockSetting('key1', 'value1');
|
|
34
34
|
const settings = new Settings({
|
|
35
|
-
serviceUrl
|
|
35
|
+
serviceUrl: `http://${serviceUrl}/`,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
const value = await settings.get('key1', 'dv');
|
|
@@ -43,7 +43,7 @@ describe('Settings', () => {
|
|
|
43
43
|
it('Cache from server', async () => {
|
|
44
44
|
const m = mockSetting('key1', 'value1');
|
|
45
45
|
const settings = new Settings({
|
|
46
|
-
serviceUrl
|
|
46
|
+
serviceUrl: `http://${serviceUrl}/`,
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
const value = await settings.get('key1', 'dv');
|
|
@@ -57,7 +57,7 @@ describe('Settings', () => {
|
|
|
57
57
|
it('Finds with labels', async () => {
|
|
58
58
|
const m = mockSetting('key1', 'value1', [{ fleetId: 'uuid' }]);
|
|
59
59
|
const settings = new Settings({
|
|
60
|
-
serviceUrl
|
|
60
|
+
serviceUrl: `http://${serviceUrl}/`,
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
const value = await settings.get('key1', 'dv', [{ fleetId: 'uuid' }]);
|
|
@@ -67,7 +67,7 @@ describe('Settings', () => {
|
|
|
67
67
|
|
|
68
68
|
it('Returns default value when network error', async () => {
|
|
69
69
|
const settings = new Settings({
|
|
70
|
-
serviceUrl
|
|
70
|
+
serviceUrl: `http://${serviceUrl}/`,
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
const value = await settings.get('key1', 'dv', [{ fleetId: 'uuid' }]);
|
|
@@ -77,7 +77,7 @@ describe('Settings', () => {
|
|
|
77
77
|
it('Values can be flushed', async () => {
|
|
78
78
|
const m1 = mockSetting('key1', 'value1');
|
|
79
79
|
const settings = new Settings({
|
|
80
|
-
serviceUrl
|
|
80
|
+
serviceUrl: `http://${serviceUrl}/`,
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
const value = await settings.get('key1', 'dv');
|