Skip to content

Commit

Permalink
remove workaround for null label
Browse files Browse the repository at this point in the history
  • Loading branch information
Eskibear committed Nov 9, 2023
1 parent 6522085 commit 47e5c34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/AzureAppConfigurationImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ export class AzureAppConfigurationImpl extends Map<string, any> implements Azure
const keyValuePair = await this.processKeyValues(setting);
keyValues.push(keyValuePair);
}
// update etag of sentinels
const matchedSentinel = this._sentinels?.find(s => s.key === setting.key && (s.label ?? null) === setting.label); // Workaround: as undefined label represents the same with null.
if (matchedSentinel) {
matchedSentinel.etag = setting.etag;
// update etag of sentinels if refresh is enabled
if (this._refreshEnabled) {
const matchedSentinel = this._sentinels.find(s => s.key === setting.key && s.label === setting.label);
if (matchedSentinel) {
matchedSentinel.etag = setting.etag;
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions test/utils/testHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AppConfigurationClient, ConfigurationSetting } from "@azure/app-configu
import { ClientSecretCredential } from "@azure/identity";
import { KeyVaultSecret, SecretClient } from "@azure/keyvault-secrets";
import * as uuid from "uuid";
import { RestError } from "@azure/core-rest-pipeline";

const TEST_CLIENT_ID = "00000000-0000-0000-0000-000000000000";
const TEST_TENANT_ID = "00000000-0000-0000-0000-000000000000";
Expand Down Expand Up @@ -39,15 +40,15 @@ function mockAppConfigurationClientListConfigurationSettings(kvList: Configurati

function mockAppConfigurationClientGetConfigurationSetting(kvList) {
sinon.stub(AppConfigurationClient.prototype, "getConfigurationSetting").callsFake((settingId, options) => {
const key = settingId.key;
const label = settingId.label ?? null;
const found = kvList.find(elem => elem.key === key && elem.label === label);
const found = kvList.find(elem => elem.key === settingId.key && elem.label === settingId.label);
if (found) {
if (options?.onlyIfChanged && settingId.etag === found.etag) {
return { statusCode: 304 };
} else {
return { statusCode: 200, ...found };
}
} else {
throw new RestError("", { statusCode: 404 });
}
});
}
Expand Down

0 comments on commit 47e5c34

Please sign in to comment.