1- import { } from 'mocha' ;
1+ import { } from 'mocha' ;
22import should from 'should' ;
33import { marshallProtobufAny } from '../src/utilts.js' ;
44import { Worker } from '../src/worker.js' ;
55import { Topic } from '@restorecommerce/kafka-client' ;
6- import {
6+ import {
77 JobServiceDefinition as SchedulingServiceDefinition ,
88 JobServiceClient as SchedulingServiceClient ,
99 JobOptions_Priority ,
@@ -92,12 +92,13 @@ interface MethodWithOutput {
9292 output : any ;
9393} ;
9494
95- const PROTO_PATH = 'io/restorecommerce/access_control.proto' ;
95+ const PROTO_PATH = './io/restorecommerce/access_control.proto' ;
96+ const PROTO_ROOT = './test/protos' ;
9697const PKG_NAME = 'io.restorecommerce.access_control' ;
9798const SERVICE_NAME = 'AccessControlService' ;
9899const pkgDef : grpc . GrpcObject = grpc . loadPackageDefinition (
99100 proto_loader . loadSync ( PROTO_PATH , {
100- includeDirs : [ 'node_modules/@restorecommerce/protos' ] ,
101+ includeDirs : PROTO_ROOT ? [ PROTO_ROOT ] : [ ] ,
101102 keepCase : true ,
102103 longs : String ,
103104 enums : String ,
@@ -210,7 +211,6 @@ describe(`testing scheduling-srv ${testSuffix}: gRPC`, () => {
210211 let grpcSchedulingSrv : SchedulingServiceClient ;
211212
212213 beforeAll ( async function ( ) : Promise < any > {
213- this . timeout ( 40000 ) ;
214214 worker = new Worker ( ) ;
215215 cfg . set ( 'events:kafka:groupId' , testSuffix + 'grpc' ) ;
216216 await worker . start ( cfg ) ;
@@ -236,9 +236,11 @@ describe(`testing scheduling-srv ${testSuffix}: gRPC`, () => {
236236 method : 'WhatIsAllowed' ,
237237 output : jobPolicySetRQ
238238 } ,
239- { method : 'IsAllowed' ,
240- output : { decision : Effect . PERMIT } }
241- ]
239+ {
240+ method : 'IsAllowed' ,
241+ output : { decision : Effect . PERMIT }
242+ }
243+ ]
242244 ) ;
243245
244246 // start mock ids-srv needed for findByToken response and return subject
@@ -279,7 +281,7 @@ describe(`testing scheduling-srv ${testSuffix}: gRPC`, () => {
279281 }
280282
281283 payloadShouldBeEmpty ( await grpcSchedulingSrv . read ( JobReadRequest . fromPartial ( { subject } ) , { } ) , false ) ;
282- } ) ;
284+ } , 40000 ) ;
283285 beforeEach ( async ( ) => {
284286 for ( const event of [ 'jobsCreated' , 'jobsDeleted' ] ) {
285287 await jobEvents . on ( event , ( ) => { } ) ;
@@ -293,7 +295,6 @@ describe(`testing scheduling-srv ${testSuffix}: gRPC`, () => {
293295 ] ) ;
294296 } ) ;
295297 afterAll ( async function ( ) : Promise < any > {
296- this . timeout ( 20000 ) ;
297298 await Promise . allSettled ( [
298299 stopACSGrpcMockServer ( ) ,
299300 stopIDSGrpcMockServer ( ) ,
@@ -303,9 +304,8 @@ describe(`testing scheduling-srv ${testSuffix}: gRPC`, () => {
303304 await worker . schedulingService . clear ( ) ,
304305 ] ) ;
305306 await worker . stop ( ) ;
306- } ) ;
307- describe ( `create a one-time job ${ testSuffix } ` , function postJob ( ) : void {
308- this . timeout ( 30000 ) ;
307+ } , 20000 ) ;
308+ describe ( `create a one-time job ${ testSuffix } ` , { timeout : 30000 } , ( ) => {
309309 it ( `should create a new job and execute it immediately ${ testSuffix } ` , async ( ) => {
310310 const w = await runWorker ( 'test-job' , 1 , cfg , logger , worker . events , async ( job ) => {
311311 validateScheduledJob ( job , 'ONCE' , logger ) ;
@@ -462,8 +462,7 @@ describe(`testing scheduling-srv ${testSuffix}: gRPC`, () => {
462462 // createResponse.operation_status!.message!.should.equal('success');
463463 // });
464464 } ) ;
465- describe ( `should create a recurring job ${ testSuffix } ` , function ( ) : void {
466- this . timeout ( 8000 ) ;
465+ describe ( `should create a recurring job ${ testSuffix } ` , { timeout : 8000 } , function ( ) : void {
467466 it ( `should create a recurring job and delete it after some executions ${ testSuffix } ` , async ( ) => {
468467 let jobExecs = 0 ;
469468 const w = await runWorker ( 'test-job' , 1 , cfg , logger , worker . events , async ( job ) => {
@@ -583,8 +582,7 @@ describe(`testing scheduling-srv ${testSuffix}: gRPC`, () => {
583582 result ! . operation_status ! . message ! . should . equal ( 'success' ) ;
584583 } ) ;
585584 } ) ;
586- describe ( `managing jobs ${ testSuffix } ` , function ( ) : void {
587- this . timeout ( 10000 ) ;
585+ describe ( `managing jobs ${ testSuffix } ` , { timeout : 10000 } , function ( ) : void {
588586 it ( 'should schedule some jobs for tomorrow' , async ( ) => {
589587 const data = {
590588 timezone : 'Europe/Berlin' ,
0 commit comments