@@ -76,6 +76,8 @@ describe('cron/psi-collect', () => {
76
76
[ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
77
77
[ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
78
78
[ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
79
+ [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
80
+ [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
79
81
] ) ;
80
82
expect ( storageMethod . sealBuild ) . toHaveBeenCalled ( ) ;
81
83
} ) ;
@@ -114,14 +116,13 @@ describe('cron/psi-collect', () => {
114
116
} ) ;
115
117
116
118
it ( 'should respect number of runs' , async ( ) => {
117
- const site = { urls : [ 'http://example.com' ] , numberOfRuns : 5 } ;
119
+ const site = { urls : [ 'http://example.com' ] , numberOfRuns : 4 } ;
118
120
await psiCollectForProject ( storageMethod , psi , site ) ;
119
121
expect ( storageMethod . createRun . mock . calls ) . toMatchObject ( [
120
122
[ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
121
123
[ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
122
124
[ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
123
125
[ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
124
- [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
125
126
] ) ;
126
127
} ) ;
127
128
@@ -137,21 +138,34 @@ describe('cron/psi-collect', () => {
137
138
} ) ;
138
139
} ) ;
139
140
140
- describe ( '.startPsiCollectCron' , ( ) => {
141
+ describe ( '.startPsiCollectCron() ' , ( ) => {
141
142
const logLevel = 'silent' ;
142
143
143
144
it ( 'should schedule a cron job per site' , ( ) => {
144
145
const psiCollectCron = {
145
146
sites : [
146
- { schedule : '0 * * * *' , urls : [ 'http://example.com' ] } ,
147
- { schedule : '0 * * * *' , urls : [ 'http://other-example.com' ] } ,
147
+ { schedule : '0 * * * *' , urls : [ 'http://example.com' ] , projectSlug : 'a' } ,
148
+ { schedule : '0 * * * *' , urls : [ 'http://other-example.com' ] , projectSlug : 'b' } ,
148
149
] ,
149
150
} ;
150
151
151
152
startPsiCollectCron ( storageMethod , { logLevel, psiCollectCron} ) ;
152
153
expect ( cronJob ) . toHaveBeenCalledTimes ( 2 ) ;
153
154
} ) ;
154
155
156
+ it ( 'should validate uniqueness' , ( ) => {
157
+ const psiCollectCron = {
158
+ sites : [
159
+ { schedule : '0 * * * *' , urls : [ 'http://example.com' ] } ,
160
+ { schedule : '0 * * * *' , urls : [ 'http://other-example.com' ] } ,
161
+ ] ,
162
+ } ;
163
+
164
+ expect ( ( ) => startPsiCollectCron ( storageMethod , { logLevel, psiCollectCron} ) ) . toThrow (
165
+ / m o r e t h a n o n e /
166
+ ) ;
167
+ } ) ;
168
+
155
169
it ( 'should validate cron job' , ( ) => {
156
170
const psiCollectCron = {
157
171
sites : [ { schedule : '* * * * *' , urls : [ 'http://example.com' ] } ] ,
0 commit comments