Skip to content

Commit 5ab92f2

Browse files
committed
test: add tests for new identity kind
1 parent df4687e commit 5ab92f2

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

spec/v2/options.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ describe("assertTimeoutSecondsValid", () => {
109109
expect(() => assertTimeoutSecondsValid({}, "event")).to.not.throw();
110110
expect(() => assertTimeoutSecondsValid({}, "https")).to.not.throw();
111111
expect(() => assertTimeoutSecondsValid({}, "task")).to.not.throw();
112+
expect(() => assertTimeoutSecondsValid({}, "identity")).to.not.throw();
112113
});
113114

114115
it("accepts values within each kind's limit", () => {
@@ -117,6 +118,7 @@ describe("assertTimeoutSecondsValid", () => {
117118
expect(() => assertTimeoutSecondsValid({ timeoutSeconds: 1800 }, "task")).to.not.throw();
118119
expect(() => assertTimeoutSecondsValid({ timeoutSeconds: 0 }, "event")).to.not.throw();
119120
expect(() => assertTimeoutSecondsValid({ timeoutSeconds: 1 }, "event")).to.not.throw();
121+
expect(() => assertTimeoutSecondsValid({ timeoutSeconds: 7 }, "identity")).to.not.throw();
120122
});
121123

122124
it("throws when timeoutSeconds exceeds the event-handler limit", () => {
@@ -137,6 +139,12 @@ describe("assertTimeoutSecondsValid", () => {
137139
);
138140
});
139141

142+
it("throws when timeoutSeconds exceeds the identity limit", () => {
143+
expect(() => assertTimeoutSecondsValid({ timeoutSeconds: 8 }, "identity")).to.throw(
144+
/between 0 and 7 for blocking functions/
145+
);
146+
});
147+
140148
it("throws when timeoutSeconds is negative", () => {
141149
expect(() => assertTimeoutSecondsValid({ timeoutSeconds: -1 }, "event")).to.throw(
142150
/between 0 and 540/
@@ -180,6 +188,8 @@ describe("assertTimeoutSecondsValid", () => {
180188
/between 0 and 540 for event-handling functions/
181189
);
182190
expect(() => assertTimeoutSecondsValid({}, "https")).to.not.throw();
191+
expect(() => assertTimeoutSecondsValid({}, "task")).to.throw();
192+
expect(() => assertTimeoutSecondsValid({}, "identity")).to.throw();
183193
});
184194

185195
it("prefers the function-level timeoutSeconds over the global one", () => {
@@ -216,12 +226,14 @@ describe("optionsToEndpoint timeout validation", () => {
216226
expect(() => optionsToEndpoint({ timeoutSeconds: 1801 }, "task")).to.throw(
217227
/between 0 and 1800/
218228
);
229+
expect(() => optionsToEndpoint({ timeoutSeconds: 8 }, "identity")).to.throw(/between 0 and 7/);
219230
});
220231

221232
it("is a no-op for in-range timeouts when kind is provided", () => {
222233
expect(() => optionsToEndpoint({ timeoutSeconds: 540 }, "event")).to.not.throw();
223234
expect(() => optionsToEndpoint({ timeoutSeconds: 3600 }, "https")).to.not.throw();
224235
expect(() => optionsToEndpoint({ timeoutSeconds: 1800 }, "task")).to.not.throw();
236+
expect(() => optionsToEndpoint({ timeoutSeconds: 7 }, "identity")).to.not.throw();
225237
});
226238
});
227239

@@ -244,11 +256,15 @@ describe("optionsToTriggerAnnotations timeout validation", () => {
244256
expect(() => optionsToTriggerAnnotations({ timeoutSeconds: 1801 }, "task")).to.throw(
245257
/between 0 and 1800/
246258
);
259+
expect(() => optionsToTriggerAnnotations({ timeoutSeconds: 8 }, "identity")).to.throw(
260+
/between 0 and 7/
261+
);
247262
});
248263

249264
it("is a no-op for in-range timeouts when kind is provided", () => {
250265
expect(() => optionsToTriggerAnnotations({ timeoutSeconds: 540 }, "event")).to.not.throw();
251266
expect(() => optionsToTriggerAnnotations({ timeoutSeconds: 3600 }, "https")).to.not.throw();
252267
expect(() => optionsToTriggerAnnotations({ timeoutSeconds: 1800 }, "task")).to.not.throw();
268+
expect(() => optionsToTriggerAnnotations({ timeoutSeconds: 7 }, "identity")).to.not.throw();
253269
});
254270
});

spec/v2/providers/timeout.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ describe("v2 provider timeout validation", () => {
6060
expectedError: /between 0 and 3600 for HTTPS and callable functions/,
6161
},
6262
{
63-
name: "identity.beforeUserCreated rejects HTTPS timeouts above 3600s",
64-
build: () => identity.beforeUserCreated({ timeoutSeconds: 3601 }, () => undefined),
65-
expectedError: /between 0 and 3600 for HTTPS and callable functions/,
63+
name: "identity.beforeUserCreated rejects blocking timeouts above 7s",
64+
build: () => identity.beforeUserCreated({ timeoutSeconds: 8 }, () => undefined),
65+
expectedError: /between 0 and 7 for blocking functions/,
6666
},
6767
{
6868
name: "tasks.onTaskDispatched rejects task timeouts above 1800s",

0 commit comments

Comments
 (0)