Skip to content

Commit 02ded28

Browse files
authored
Assert error messages and increase timeout for tests (#48)
1 parent ed6688a commit 02ded28

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/load.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function load(
4848
endpoint = new URL(endpoint);
4949
} catch (error) {
5050
if (error.code === "ERR_INVALID_URL") {
51-
throw new Error("Invalid Endpoint URL.", { cause: error });
51+
throw new Error("Invalid endpoint URL.", { cause: error });
5252
} else {
5353
throw error;
5454
}

test/keyvault.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function mockNewlyCreatedKeyVaultSecretClients() {
2727
mockSecretClientGetSecret(mockedData.map(([_key, secretUri, value]) => [secretUri, value]));
2828
}
2929
describe("key vault reference", function () {
30+
this.timeout(10000);
31+
3032
beforeEach(() => {
3133
mockAppConfigurationClient();
3234
mockNewlyCreatedKeyVaultSecretClients();
@@ -37,7 +39,7 @@ describe("key vault reference", function () {
3739
});
3840

3941
it("require key vault options to resolve reference", async () => {
40-
expect(load(createMockedConnectionString())).eventually.rejected;
42+
return expect(load(createMockedConnectionString())).eventually.rejectedWith("Configure keyVaultOptions to resolve Key Vault Reference(s).");
4143
});
4244

4345
it("should resolve key vault reference with credential", async () => {
@@ -93,7 +95,7 @@ describe("key vault reference", function () {
9395
]
9496
}
9597
});
96-
expect(loadKeyVaultPromise).eventually.rejected;
98+
return expect(loadKeyVaultPromise).eventually.rejectedWith("No key vault credential or secret resolver callback configured, and no matching secret client could be found.");
9799
});
98100

99101
it("should fallback to use default credential when corresponding secret client not provided", async () => {

test/load.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const mockedKVs = [{
3131
}].map(createMockedKeyValue);
3232

3333
describe("load", function () {
34+
this.timeout(10000);
35+
3436
before(() => {
3537
mockAppConfigurationClientListConfigurationSettings(mockedKVs);
3638
});
@@ -65,12 +67,12 @@ describe("load", function () {
6567
});
6668

6769
it("should throw error given invalid connection string", async () => {
68-
expect(load("invalid-connection-string")).eventually.rejected;
70+
return expect(load("invalid-connection-string")).eventually.rejectedWith("Invalid connection string.");
6971
});
7072

7173
it("should throw error given invalid endpoint URL", async () => {
7274
const credential = createMockedTokenCredential();
73-
expect(load("invalid-endpoint-url", credential)).eventually.rejected;
75+
return expect(load("invalid-endpoint-url", credential)).eventually.rejectedWith("Invalid endpoint URL.");
7476
});
7577

7678
it("should trim key prefix if applicable", async () => {
@@ -117,23 +119,26 @@ describe("load", function () {
117119
expect(settings.get("KeyForEmptyValue")).eq("");
118120
});
119121

120-
it("should not support * or , in label filters", async () => {
122+
it("should not support * in label filters", async () => {
121123
const connectionString = createMockedConnectionString();
122124
const loadWithWildcardLabelFilter = load(connectionString, {
123125
selectors: [{
124126
keyFilter: "app.*",
125127
labelFilter: "*"
126128
}]
127129
});
128-
expect(loadWithWildcardLabelFilter).to.eventually.rejected;
130+
return expect(loadWithWildcardLabelFilter).to.eventually.rejectedWith("The characters '*' and ',' are not supported in label filters.");
131+
});
129132

133+
it("should not support , in label filters", async () => {
134+
const connectionString = createMockedConnectionString();
130135
const loadWithMultipleLabelFilter = load(connectionString, {
131136
selectors: [{
132137
keyFilter: "app.*",
133138
labelFilter: "labelA,labelB"
134139
}]
135140
});
136-
expect(loadWithMultipleLabelFilter).to.eventually.rejected;
141+
return expect(loadWithMultipleLabelFilter).to.eventually.rejectedWith("The characters '*' and ',' are not supported in label filters.");
137142
});
138143

139144
it("should override config settings with same key but different label", async () => {

0 commit comments

Comments
 (0)