Skip to content

Commit 47e5c34

Browse files
committed
remove workaround for null label
1 parent 6522085 commit 47e5c34

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/AzureAppConfigurationImpl.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ export class AzureAppConfigurationImpl extends Map<string, any> implements Azure
100100
const keyValuePair = await this.processKeyValues(setting);
101101
keyValues.push(keyValuePair);
102102
}
103-
// update etag of sentinels
104-
const matchedSentinel = this._sentinels?.find(s => s.key === setting.key && (s.label ?? null) === setting.label); // Workaround: as undefined label represents the same with null.
105-
if (matchedSentinel) {
106-
matchedSentinel.etag = setting.etag;
103+
// update etag of sentinels if refresh is enabled
104+
if (this._refreshEnabled) {
105+
const matchedSentinel = this._sentinels.find(s => s.key === setting.key && s.label === setting.label);
106+
if (matchedSentinel) {
107+
matchedSentinel.etag = setting.etag;
108+
}
107109
}
108110
}
109111
}

test/utils/testHelper.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { AppConfigurationClient, ConfigurationSetting } from "@azure/app-configu
66
import { ClientSecretCredential } from "@azure/identity";
77
import { KeyVaultSecret, SecretClient } from "@azure/keyvault-secrets";
88
import * as uuid from "uuid";
9+
import { RestError } from "@azure/core-rest-pipeline";
910

1011
const TEST_CLIENT_ID = "00000000-0000-0000-0000-000000000000";
1112
const TEST_TENANT_ID = "00000000-0000-0000-0000-000000000000";
@@ -39,15 +40,15 @@ function mockAppConfigurationClientListConfigurationSettings(kvList: Configurati
3940

4041
function mockAppConfigurationClientGetConfigurationSetting(kvList) {
4142
sinon.stub(AppConfigurationClient.prototype, "getConfigurationSetting").callsFake((settingId, options) => {
42-
const key = settingId.key;
43-
const label = settingId.label ?? null;
44-
const found = kvList.find(elem => elem.key === key && elem.label === label);
43+
const found = kvList.find(elem => elem.key === settingId.key && elem.label === settingId.label);
4544
if (found) {
4645
if (options?.onlyIfChanged && settingId.etag === found.etag) {
4746
return { statusCode: 304 };
4847
} else {
4948
return { statusCode: 200, ...found };
5049
}
50+
} else {
51+
throw new RestError("", { statusCode: 404 });
5152
}
5253
});
5354
}

0 commit comments

Comments
 (0)