View Javadoc
1   /*
2    * Copyright (C) 2016, Matthias Sohn <matthias.sohn@sap.com> and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  package org.eclipse.jgit.internal.storage.file;
11  
12  import static org.junit.Assert.assertFalse;
13  import static org.junit.Assert.assertTrue;
14  
15  import org.eclipse.jgit.lib.ConfigConstants;
16  import org.eclipse.jgit.storage.file.FileBasedConfig;
17  import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
18  import org.junit.Test;
19  
20  public class AutoGcTest extends GcTestCase {
21  
22  	@Test
23  	public void testNotTooManyLooseObjects() {
24  		assertFalse("should not find too many loose objects",
25  				gc.tooManyLooseObjects());
26  	}
27  
28  	@Test
29  	public void testTooManyLooseObjects() throws Exception {
30  		FileBasedConfig c = repo.getConfig();
31  		c.setInt(ConfigConstants.CONFIG_GC_SECTION, null,
32  				ConfigConstants.CONFIG_KEY_AUTO, 255);
33  		c.save();
34  		commitChain(10, 50);
35  		assertTrue("should find too many loose objects",
36  				gc.tooManyLooseObjects());
37  	}
38  
39  	@Test
40  	public void testNotTooManyPacks() {
41  		assertFalse("should not find too many packs", gc.tooManyPacks());
42  	}
43  
44  	@Test
45  	public void testTooManyPacks() throws Exception {
46  		FileBasedConfig c = repo.getConfig();
47  		c.setInt(ConfigConstants.CONFIG_GC_SECTION, null,
48  				ConfigConstants.CONFIG_KEY_AUTOPACKLIMIT, 1);
49  		c.save();
50  		SampleDataRepositoryTestCase.copyCGitTestPacks(repo);
51  
52  		assertTrue("should find too many packs", gc.tooManyPacks());
53  	}
54  }