|
1 | 1 | import { expect } from "chai";
|
2 |
| -import { stackToWire, ManifestStack } from "../../src/runtime/manifest"; |
| 2 | +import { |
| 3 | + stackToWire, |
| 4 | + ManifestStack, |
| 5 | + initV2ScheduleTrigger, |
| 6 | + initV1ScheduleTrigger, |
| 7 | + initTaskQueueTrigger, |
| 8 | +} from "../../src/runtime/manifest"; |
| 9 | +import { RESET_VALUE } from "../../src/common/options"; |
3 | 10 | import * as params from "../../src/params";
|
4 | 11 | import * as optsv2 from "../../src/v2/options";
|
5 | 12 | import * as v1 from "../../src/v1";
|
| 13 | +import { DeploymentOptions } from "../../src/v1"; |
6 | 14 |
|
7 | 15 | describe("stackToWire", () => {
|
8 | 16 | afterEach(() => {
|
@@ -168,3 +176,90 @@ describe("stackToWire", () => {
|
168 | 176 | expect(stackToWire(stack)).to.deep.equal(expected);
|
169 | 177 | });
|
170 | 178 | });
|
| 179 | + |
| 180 | +describe("initTaskQueueTrigger", () => { |
| 181 | + it("should init a taskQueueTrigger without preserveExternalChanges", () => { |
| 182 | + const tt = initTaskQueueTrigger(); |
| 183 | + |
| 184 | + expect(tt).to.deep.eq({ |
| 185 | + retryConfig: { |
| 186 | + maxAttempts: RESET_VALUE, |
| 187 | + maxDoublings: RESET_VALUE, |
| 188 | + maxBackoffSeconds: RESET_VALUE, |
| 189 | + maxRetrySeconds: RESET_VALUE, |
| 190 | + minBackoffSeconds: RESET_VALUE, |
| 191 | + }, |
| 192 | + rateLimits: { |
| 193 | + maxConcurrentDispatches: RESET_VALUE, |
| 194 | + maxDispatchesPerSecond: RESET_VALUE, |
| 195 | + }, |
| 196 | + }); |
| 197 | + }); |
| 198 | + |
| 199 | + it("should init a taskQueueTrigger with preserveExternalChanges", () => { |
| 200 | + const opts: DeploymentOptions = { preserveExternalChanges: true }; |
| 201 | + |
| 202 | + const tt = initTaskQueueTrigger(opts); |
| 203 | + |
| 204 | + expect(tt).to.deep.eq({ |
| 205 | + rateLimits: {}, |
| 206 | + retryConfig: {}, |
| 207 | + }); |
| 208 | + }); |
| 209 | +}); |
| 210 | + |
| 211 | +describe("initScheduleTrigger", () => { |
| 212 | + it("should init a v1 scheduleTrigger without preserveExternalChanges", () => { |
| 213 | + const st = initV1ScheduleTrigger("every 30 minutes"); |
| 214 | + |
| 215 | + expect(st).to.deep.eq({ |
| 216 | + schedule: "every 30 minutes", |
| 217 | + timeZone: RESET_VALUE, |
| 218 | + retryConfig: { |
| 219 | + retryCount: RESET_VALUE, |
| 220 | + maxDoublings: RESET_VALUE, |
| 221 | + maxRetryDuration: RESET_VALUE, |
| 222 | + minBackoffDuration: RESET_VALUE, |
| 223 | + maxBackoffDuration: RESET_VALUE, |
| 224 | + }, |
| 225 | + }); |
| 226 | + }); |
| 227 | + |
| 228 | + it("should init a v1 scheduleTrigger with preserveExternalChanges", () => { |
| 229 | + const opts: DeploymentOptions = { preserveExternalChanges: true }; |
| 230 | + |
| 231 | + const st = initV1ScheduleTrigger("every 30 minutes", opts); |
| 232 | + |
| 233 | + expect(st).to.deep.eq({ |
| 234 | + schedule: "every 30 minutes", |
| 235 | + retryConfig: {}, |
| 236 | + }); |
| 237 | + }); |
| 238 | + |
| 239 | + it("should init a v2 scheduleTrigger without preserveExternalChanges", () => { |
| 240 | + const st = initV2ScheduleTrigger("every 30 minutes"); |
| 241 | + |
| 242 | + expect(st).to.deep.eq({ |
| 243 | + schedule: "every 30 minutes", |
| 244 | + timeZone: RESET_VALUE, |
| 245 | + retryConfig: { |
| 246 | + retryCount: RESET_VALUE, |
| 247 | + maxDoublings: RESET_VALUE, |
| 248 | + maxRetrySeconds: RESET_VALUE, |
| 249 | + minBackoffSeconds: RESET_VALUE, |
| 250 | + maxBackoffSeconds: RESET_VALUE, |
| 251 | + }, |
| 252 | + }); |
| 253 | + }); |
| 254 | + |
| 255 | + it("should init a v2 scheduleTrigger with preserveExternalChanges", () => { |
| 256 | + const opts: DeploymentOptions = { preserveExternalChanges: true }; |
| 257 | + |
| 258 | + const st = initV2ScheduleTrigger("every 30 minutes", opts); |
| 259 | + |
| 260 | + expect(st).to.deep.eq({ |
| 261 | + schedule: "every 30 minutes", |
| 262 | + retryConfig: {}, |
| 263 | + }); |
| 264 | + }); |
| 265 | +}); |
0 commit comments