@@ -76,6 +76,8 @@ describe('cron/psi-collect', () => {
7676 [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
7777 [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
7878 [ { 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}' } ] ,
7981 ] ) ;
8082 expect ( storageMethod . sealBuild ) . toHaveBeenCalled ( ) ;
8183 } ) ;
@@ -114,14 +116,13 @@ describe('cron/psi-collect', () => {
114116 } ) ;
115117
116118 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 } ;
118120 await psiCollectForProject ( storageMethod , psi , site ) ;
119121 expect ( storageMethod . createRun . mock . calls ) . toMatchObject ( [
120122 [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
121123 [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
122124 [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
123125 [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
124- [ { projectId : 1 , buildId : 2 , url : 'http://example.com' , lhr : '{"lhr": true}' } ] ,
125126 ] ) ;
126127 } ) ;
127128
@@ -137,21 +138,34 @@ describe('cron/psi-collect', () => {
137138 } ) ;
138139 } ) ;
139140
140- describe ( '.startPsiCollectCron' , ( ) => {
141+ describe ( '.startPsiCollectCron() ' , ( ) => {
141142 const logLevel = 'silent' ;
142143
143144 it ( 'should schedule a cron job per site' , ( ) => {
144145 const psiCollectCron = {
145146 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' } ,
148149 ] ,
149150 } ;
150151
151152 startPsiCollectCron ( storageMethod , { logLevel, psiCollectCron} ) ;
152153 expect ( cronJob ) . toHaveBeenCalledTimes ( 2 ) ;
153154 } ) ;
154155
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+
155169 it ( 'should validate cron job' , ( ) => {
156170 const psiCollectCron = {
157171 sites : [ { schedule : '* * * * *' , urls : [ 'http://example.com' ] } ] ,
0 commit comments