@@ -2,7 +2,7 @@ import '../../__mocks__/_extendJest'
2
2
import { runAllTimers , waitUntil } from '../../__mocks__/helpers/jest'
3
3
import { MeteorMock } from '../../__mocks__/meteor'
4
4
import { logger } from '../logging'
5
- import { getRandomId , getRandomString , protectString } from '../lib/tempLib'
5
+ import { getRandomId , getRandomString , literal , protectString } from '../lib/tempLib'
6
6
import { SnapshotType } from '@sofie-automation/meteor-lib/dist/collections/Snapshots'
7
7
import { IBlueprintPieceType , PieceLifespan , StatusCode , TSR } from '@sofie-automation/blueprints-integration'
8
8
import {
@@ -64,26 +64,36 @@ import {
64
64
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
65
65
import { Settings } from '../Settings'
66
66
import { SofieIngestCacheType } from '@sofie-automation/corelib/dist/dataModel/SofieIngestDataCache'
67
+ import { ObjectOverrideSetOp } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
67
68
68
69
describe ( 'cronjobs' , ( ) => {
69
70
let env : DefaultEnvironment
70
71
let rundownId : RundownId
71
72
72
- beforeAll ( async ( ) => {
73
- env = await setupDefaultStudioEnvironment ( )
74
-
75
- const o = await setupDefaultRundownPlaylist ( env )
76
- rundownId = o . rundownId
77
-
73
+ async function setCasparCGCronEnabled ( enabled : boolean ) {
78
74
await CoreSystem . updateAsync (
79
75
{ } ,
80
76
{
81
- $set : {
82
- 'cron.casparCGRestart.enabled' : true ,
77
+ // This is a little bit of a hack, as it will result in duplicate ops, but it's fine for unit tests
78
+ $push : {
79
+ 'settingsWithOverrides.overrides' : literal < ObjectOverrideSetOp > ( {
80
+ op : 'set' ,
81
+ path : 'cron.casparCGRestart.enabled' ,
82
+ value : enabled ,
83
+ } ) ,
83
84
} ,
84
85
} ,
85
86
{ multi : true }
86
87
)
88
+ }
89
+
90
+ beforeAll ( async ( ) => {
91
+ env = await setupDefaultStudioEnvironment ( )
92
+
93
+ const o = await setupDefaultRundownPlaylist ( env )
94
+ rundownId = o . rundownId
95
+
96
+ await setCasparCGCronEnabled ( true )
87
97
88
98
jest . useFakeTimers ( )
89
99
// set time to 2020/07/19 00:00 Local Time
@@ -597,15 +607,7 @@ describe('cronjobs', () => {
597
607
} )
598
608
test ( 'Does not attempt to restart CasparCG when job is disabled' , async ( ) => {
599
609
await createMockPlayoutGatewayAndDevices ( Date . now ( ) ) // Some time after the threshold
600
- await CoreSystem . updateAsync (
601
- { } ,
602
- {
603
- $set : {
604
- 'cron.casparCGRestart.enabled' : false ,
605
- } ,
606
- } ,
607
- { multi : true }
608
- )
610
+ await setCasparCGCronEnabled ( false )
609
611
; ( logger . info as jest . Mock ) . mockClear ( )
610
612
// set time to 2020/07/{date} 04:05 Local Time, should be more than 24 hours after 2020/07/19 00:00 UTC
611
613
mockCurrentTime = new Date ( 2020 , 6 , date ++ , 4 , 5 , 0 ) . getTime ( )
0 commit comments