1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.internal.storage.file;
12
13 import static org.junit.Assert.assertEquals;
14
15 import org.eclipse.jgit.junit.TestRepository.BranchBuilder;
16 import org.junit.Test;
17
18 public class GcDirCacheSavesObjectsTest extends GcTestCase {
19 @Test
20 public void testDirCacheSavesObjects() throws Exception {
21 BranchBuilder bb = tr.branch("refs/heads/master");
22 bb.commit().add("A", "A").add("B", "B").create();
23 bb.commit().add("A", "A2").add("B", "B2").create();
24 bb.commit().add("A", "A3");
25 stats = gc.getStatistics();
26 assertEquals(9, stats.numberOfLooseObjects);
27 assertEquals(0, stats.numberOfPackedObjects);
28 gc.gc().get();
29 stats = gc.getStatistics();
30 assertEquals(1, stats.numberOfLooseObjects);
31 assertEquals(8, stats.numberOfPackedObjects);
32 assertEquals(1, stats.numberOfPackFiles);
33 }
34
35 @Test
36 public void testDirCacheSavesObjectsWithPruneNow() throws Exception {
37 BranchBuilder bb = tr.branch("refs/heads/master");
38 bb.commit().add("A", "A").add("B", "B").create();
39 bb.commit().add("A", "A2").add("B", "B2").create();
40 bb.commit().add("A", "A3");
41 stats = gc.getStatistics();
42 assertEquals(9, stats.numberOfLooseObjects);
43 assertEquals(0, stats.numberOfPackedObjects);
44 gc.setExpireAgeMillis(0);
45 fsTick();
46 gc.gc().get();
47 stats = gc.getStatistics();
48 assertEquals(0, stats.numberOfLooseObjects);
49 assertEquals(8, stats.numberOfPackedObjects);
50 assertEquals(1, stats.numberOfPackFiles);
51 }
52 }