t1700: test shared index file expiration

Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Mar 6, 2017 at 10:41 UTC c0441f7ef3e9e9a8ee7888e00472c6957bd90b2d
1 file changed +44
t/t1700-split-index.sh
+44
@@ -310,4 +310,48 @@ test_expect_success 'check splitIndex.maxPercentChange set to 0' '
310 test_cmp expect actual
311 '
312
313 +test_expect_success 'shared index files expire after 2 weeks by default' '
314 + : >ten &&
315 + git update-index --add ten &&
316 + test $(ls .git/sharedindex.* | wc -l) -gt 1 &&
317 + just_under_2_weeks_ago=$((5-14*86400)) &&
318 + test-chmtime =$just_under_2_weeks_ago .git/sharedindex.* &&
319 + : >eleven &&
320 + git update-index --add eleven &&
321 + test $(ls .git/sharedindex.* | wc -l) -gt 1 &&
322 + just_over_2_weeks_ago=$((-1-14*86400)) &&
323 + test-chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
324 + : >twelve &&
325 + git update-index --add twelve &&
326 + test $(ls .git/sharedindex.* | wc -l) = 1
327 +'
328 +
329 +test_expect_success 'check splitIndex.sharedIndexExpire set to 16 days' '
330 + git config splitIndex.sharedIndexExpire "16.days.ago" &&
331 + test-chmtime =$just_over_2_weeks_ago .git/sharedindex.* &&
332 + : >thirteen &&
333 + git update-index --add thirteen &&
334 + test $(ls .git/sharedindex.* | wc -l) -gt 1 &&
335 + just_over_16_days_ago=$((-1-16*86400)) &&
336 + test-chmtime =$just_over_16_days_ago .git/sharedindex.* &&
337 + : >fourteen &&
338 + git update-index --add fourteen &&
339 + test $(ls .git/sharedindex.* | wc -l) = 1
340 +'
341 +
342 +test_expect_success 'check splitIndex.sharedIndexExpire set to "never" and "now"' '
343 + git config splitIndex.sharedIndexExpire never &&
344 + just_10_years_ago=$((-365*10*86400)) &&
345 + test-chmtime =$just_10_years_ago .git/sharedindex.* &&
346 + : >fifteen &&
347 + git update-index --add fifteen &&
348 + test $(ls .git/sharedindex.* | wc -l) -gt 1 &&
349 + git config splitIndex.sharedIndexExpire now &&
350 + just_1_second_ago=-1 &&
351 + test-chmtime =$just_1_second_ago .git/sharedindex.* &&
352 + : >sixteen &&
353 + git update-index --add sixteen &&
354 + test $(ls .git/sharedindex.* | wc -l) = 1
355 +'
356 +
357 test_done