From e49e4ae035d0d7936b0f331c257aac4984c48665 Mon Sep 17 00:00:00 2001 From: Yan Zhang Date: Mon, 18 Sep 2023 21:58:42 +0800 Subject: [PATCH] Fix: should load settings with empty/null value --- src/AzureAppConfigurationImpl.ts | 2 +- test/load.test.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/AzureAppConfigurationImpl.ts b/src/AzureAppConfigurationImpl.ts index b54c00cb..0403aed4 100644 --- a/src/AzureAppConfigurationImpl.ts +++ b/src/AzureAppConfigurationImpl.ts @@ -40,7 +40,7 @@ export class AzureAppConfigurationImpl extends Map implements A }); for await (const setting of settings) { - if (setting.key && setting.value) { + if (setting.key) { const [key, value] = await this.processAdapters(setting); const trimmedKey = this.keyWithPrefixesTrimmed(key); keyValues.push([trimmedKey, value]); diff --git a/test/load.test.js b/test/load.test.js index 3d247fb7..1ff74c3c 100644 --- a/test/load.test.js +++ b/test/load.test.js @@ -41,6 +41,24 @@ const mockedKVs = [{ tags: {}, etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk', isReadOnly: false +}, { + value: null, + key: 'KeyForNullValue', + label: '', + contentType: '', + lastModified: '2023-05-04T04:32:56.000Z', + tags: {}, + etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk', + isReadOnly: false +}, { + value: "", + key: 'KeyForEmptyValue', + label: '', + contentType: '', + lastModified: '2023-05-04T04:32:56.000Z', + tags: {}, + etag: 'GdmsLWq3mFjFodVEXUYRmvFr3l_qRiKAW_KdpFbxZKk', + isReadOnly: false }]; describe("load", function () { @@ -121,4 +139,14 @@ describe("load", function () { expect(settings.has("Key")).eq(true); expect(settings.get("Key")).eq("TestValue"); }); + + it("should support null/empty value", async () => { + const connectionString = createMockedConnectionString(); + const settings = await load(connectionString); + expect(settings).not.undefined; + expect(settings.has("KeyForNullValue")).eq(true); + expect(settings.get("KeyForNullValue")).eq(null); + expect(settings.has("KeyForEmptyValue")).eq(true); + expect(settings.get("KeyForEmptyValue")).eq(""); + }); })