Skip to content

Commit 506c8a6

Browse files
committed
throw error on refresh when refresh is not enabled
1 parent 98b12e2 commit 506c8a6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/AzureAppConfigurationImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class AzureAppConfigurationImpl extends Map<string, any> implements Azure
132132
*/
133133
public async refresh(): Promise<void> {
134134
if (!this.#refreshEnabled) {
135-
return Promise.resolve();
135+
throw new Error("Refresh is not enabled.");
136136
}
137137

138138
// if still within refresh interval/backoff, return

test/refresh.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ describe("dynamic refresh", function () {
3838
restoreMocks();
3939
})
4040

41+
it("should throw error when refresh is not enabled but refresh is called", async () => {
42+
const connectionString = createMockedConnectionString();
43+
const settings = await load(connectionString);
44+
const refreshCall = settings.refresh();
45+
return expect(refreshCall).eventually.rejectedWith("Refresh is not enabled.");
46+
});
47+
4148
it("should only allow non-empty list of watched settings when refresh is enabled", async () => {
4249
const connectionString = createMockedConnectionString();
4350
const loadWithEmptyWatchedSettings = load(connectionString, {

0 commit comments

Comments
 (0)