@@ -28,6 +28,7 @@ import { MINIMAL_V2_ENDPOINT } from "../../fixtures";
2828import { onInit } from "../../../src/v2/core" ;
2929import { MockRequest } from "../../fixtures/mockrequest" ;
3030import { runHandler } from "../../helper" ;
31+ import * as params from "../../../src/params" ;
3132
3233const MINIMAL_SCHEDULE_TRIGGER : ManifestEndpoint [ "scheduleTrigger" ] = {
3334 schedule : "" ,
@@ -67,7 +68,6 @@ describe("schedule", () => {
6768 expect ( schedule . getOpts ( options ) ) . to . deep . eq ( {
6869 schedule : "* * * * *" ,
6970 timeZone : "utc" ,
70- attemptDeadlineSeconds : undefined ,
7171 retryConfig : {
7272 retryCount : 3 ,
7373 maxRetrySeconds : 1 ,
@@ -110,7 +110,7 @@ describe("schedule", () => {
110110 {
111111 schedule : "* * * * *" ,
112112 timeZone : "utc" ,
113- attemptDeadlineSeconds : 300 ,
113+ timeoutSeconds : 300 ,
114114 retryCount : 3 ,
115115 maxRetrySeconds : 10 ,
116116 minBackoffSeconds : 11 ,
@@ -127,6 +127,7 @@ describe("schedule", () => {
127127 platform : "gcfv2" ,
128128 labels : { key : "val" } ,
129129 region : [ "us-central1" ] ,
130+ timeoutSeconds : 300 ,
130131 scheduleTrigger : {
131132 schedule : "* * * * *" ,
132133 timeZone : "utc" ,
@@ -157,13 +158,12 @@ describe("schedule", () => {
157158 ( ) => console . log ( 1 )
158159 ) ;
159160
160- expect ( schfn . __endpoint ) . to . deep . eq ( {
161+ expect ( schfn . __endpoint ) . to . deep . equal ( {
161162 platform : "gcfv2" ,
162163 labels : { } ,
163164 scheduleTrigger : {
164165 schedule : "* * * * *" ,
165166 timeZone : undefined ,
166- attemptDeadlineSeconds : undefined ,
167167 retryConfig : {
168168 retryCount : undefined ,
169169 maxRetrySeconds : undefined ,
@@ -181,6 +181,33 @@ describe("schedule", () => {
181181 ] ) ;
182182 } ) ;
183183
184+ it ( "should set attemptDeadlineSeconds from timeoutSeconds" , ( ) => {
185+ const schfn = schedule . onSchedule (
186+ {
187+ schedule : "* * * * *" ,
188+ timeoutSeconds : 3600 ,
189+ } ,
190+ ( ) => undefined
191+ ) ;
192+
193+ expect ( schfn . __endpoint . timeoutSeconds ) . to . deep . eq ( 3600 ) ;
194+ expect ( schfn . __endpoint . scheduleTrigger ?. attemptDeadlineSeconds ) . to . deep . eq ( 3600 ) ;
195+ } ) ;
196+
197+ it ( "should set attemptDeadlineSeconds from Expression timeoutSeconds" , ( ) => {
198+ const timeout = params . defineInt ( "TIMEOUT" ) ;
199+ const schfn = schedule . onSchedule (
200+ {
201+ schedule : "* * * * *" ,
202+ timeoutSeconds : timeout ,
203+ } ,
204+ ( ) => undefined
205+ ) ;
206+
207+ expect ( schfn . __endpoint . timeoutSeconds ) . to . deep . eq ( timeout ) ;
208+ expect ( schfn . __endpoint . scheduleTrigger ?. attemptDeadlineSeconds ) . to . deep . eq ( timeout ) ;
209+ } ) ;
210+
184211 it ( "should have a .run method" , async ( ) => {
185212 const testObj = {
186213 foo : "bar" ,
0 commit comments