@@ -110,7 +110,7 @@ export default () =>
110110 await assert . doesNotReject ( resultPromise , 'The request should succeed' ) ;
111111 res = await resultPromise ;
112112 } )
113-
113+
114114 it ( 'returns status 200' , async function ( ) {
115115 assert . strictEqual ( res . status , 200 ) ;
116116 } ) ;
@@ -176,27 +176,62 @@ export default () =>
176176 it ( 'can also write hashes to repo.xml' , async ( ) => {
177177 await remove ( ) ;
178178 await install ( ) ;
179-
179+
180180 // Set up tuttle with a repo where repo.xml is used to store the git sha info
181181 const buffer = await readFile ( './test/fixtures/alt-repoxml-tuttle.xml' ) ;
182182 await putResource ( buffer , '/db/apps/tuttle/data/tuttle.xml' ) ;
183-
183+
184184 const resultPromise = axios . get ( 'git/status' , { auth } ) ;
185185 await assert . doesNotReject ( resultPromise ) ;
186-
186+
187187 const stagingPromise = axios . get ( 'git/tuttle-sample-data' , { auth } ) ;
188188 await assert . doesNotReject ( stagingPromise , 'The request should succeed' ) ;
189189
190190 const deployPromise = axios . post ( 'git/tuttle-sample-data' , { } , { auth } ) ;
191191 await assert . doesNotReject ( deployPromise , 'The request should succeed' ) ;
192-
192+
193193 const repoXML = await getResource ( '/db/apps/tuttle-sample-data/repo.xml' ) ;
194-
194+
195195 const repo = new DOMParser ( ) . parseFromString ( repoXML . toString ( ) , 'text/xml' ) . documentElement ;
196196 assert . ok ( repo . getAttribute ( 'commit-id' ) , 'The commit id should be set' ) ;
197197 assert . ok ( repo . getAttribute ( 'commit-time' ) , 'The commit time should be set' ) ;
198198 assert . ok ( repo . getAttribute ( 'commit-date' ) , 'The commit date should be set' ) ;
199199 } ) ;
200-
201- } ) ;
202200
201+ describe ( 'large histories' , async ( ) => {
202+ before ( async ( ) => {
203+ await remove ( ) ;
204+ await install ( ) ;
205+ } ) ;
206+
207+ await it ( 'can upgrade over a few hundred commits' , async ( ) => {
208+ // Set up tuttle with a repo with a ton of commits that it can upgrade over
209+ const buffer = await readFile ( './test/fixtures/alt-big-repo-tuttle.xml' ) ;
210+ await putResource ( buffer , '/db/apps/tuttle/data/tuttle.xml' ) ;
211+
212+ const OLD_HASH = '41188098f120b6e70d1b0c3bb704a422eba43dfa' ;
213+ const stageOldVersionPromise = axios . get ( `git/tuttle-sample-data?hash=${ OLD_HASH } ` , { auth } ) ;
214+ await assert . doesNotReject ( stageOldVersionPromise ) ;
215+ const deployOldVersionPromise = axios . post ( 'git/tuttle-sample-data' , { } , { auth } ) ;
216+ await assert . doesNotReject ( deployOldVersionPromise , 'The request should succeed' ) ;
217+
218+ const beforeString = await getResource ( '/db/apps/tuttle-sample-data/data/regular-changing-document.xml' ) ;
219+
220+ const before = new DOMParser ( ) . parseFromString ( beforeString . toString ( ) , 'text/xml' ) . documentElement ;
221+ assert . strictEqual ( before . textContent , 'Initial version' ) ;
222+
223+ console . log ( 'deployed older version of the sample data on the long-history branch' )
224+
225+ const resultPromise = axios . get ( 'git/status' , { auth } ) ;
226+ await assert . doesNotReject ( resultPromise ) ;
227+
228+ const incrementalPromise = axios . post ( 'git/tuttle-sample-data/incremental' , { } , { auth } ) ;
229+ await assert . doesNotReject ( incrementalPromise , 'The incremental request should succeed' ) ;
230+
231+ const afterString = await getResource ( '/db/apps/tuttle-sample-data/data/regular-changing-document.xml' ) ;
232+
233+ const after = new DOMParser ( ) . parseFromString ( afterString . toString ( ) , 'text/xml' ) . documentElement ;
234+ assert . strictEqual ( after . textContent , 'change for 200' ) ;
235+ } ) ;
236+ } ) ;
237+ } ) ;
0 commit comments