Skip to content

Commit c1b8595

Browse files
authored
Fix: should load settings with empty/null value (#9)
1 parent cf277a9 commit c1b8595

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/AzureAppConfigurationImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class AzureAppConfigurationImpl extends Map<string, unknown> implements A
4040
});
4141

4242
for await (const setting of settings) {
43-
if (setting.key && setting.value) {
43+
if (setting.key) {
4444
const [key, value] = await this.processAdapters(setting);
4545
const trimmedKey = this.keyWithPrefixesTrimmed(key);
4646
keyValues.push([trimmedKey, value]);

test/load.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ const mockedKVs = [{
4141
tags: {},
4242
etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk',
4343
isReadOnly: false
44+
}, {
45+
value: null,
46+
key: 'KeyForNullValue',
47+
label: '',
48+
contentType: '',
49+
lastModified: '2023-05-04T04:32:56.000Z',
50+
tags: {},
51+
etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk',
52+
isReadOnly: false
53+
}, {
54+
value: "",
55+
key: 'KeyForEmptyValue',
56+
label: '',
57+
contentType: '',
58+
lastModified: '2023-05-04T04:32:56.000Z',
59+
tags: {},
60+
etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk',
61+
isReadOnly: false
4462
}];
4563

4664
describe("load", function () {
@@ -121,4 +139,14 @@ describe("load", function () {
121139
expect(settings.has("Key")).eq(true);
122140
expect(settings.get("Key")).eq("TestValue");
123141
});
142+
143+
it("should support null/empty value", async () => {
144+
const connectionString = createMockedConnectionString();
145+
const settings = await load(connectionString);
146+
expect(settings).not.undefined;
147+
expect(settings.has("KeyForNullValue")).eq(true);
148+
expect(settings.get("KeyForNullValue")).eq(null);
149+
expect(settings.has("KeyForEmptyValue")).eq(true);
150+
expect(settings.get("KeyForEmptyValue")).eq("");
151+
});
124152
})

0 commit comments

Comments
 (0)