You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AutoGcTest.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. import static org.junit.Assert.assertFalse;
  12. import static org.junit.Assert.assertTrue;
  13. import org.eclipse.jgit.lib.ConfigConstants;
  14. import org.eclipse.jgit.storage.file.FileBasedConfig;
  15. import org.eclipse.jgit.test.resources.SampleDataRepositoryTestCase;
  16. import org.junit.Test;
  17. public class AutoGcTest extends GcTestCase {
  18. @Test
  19. public void testNotTooManyLooseObjects() {
  20. assertFalse("should not find too many loose objects",
  21. gc.tooManyLooseObjects());
  22. }
  23. @Test
  24. public void testTooManyLooseObjects() throws Exception {
  25. FileBasedConfig c = repo.getConfig();
  26. c.setInt(ConfigConstants.CONFIG_GC_SECTION, null,
  27. ConfigConstants.CONFIG_KEY_AUTO, 255);
  28. c.save();
  29. commitChain(10, 50);
  30. assertTrue("should find too many loose objects",
  31. gc.tooManyLooseObjects());
  32. }
  33. @Test
  34. public void testNotTooManyPacks() {
  35. assertFalse("should not find too many packs", gc.tooManyPacks());
  36. }
  37. @Test
  38. public void testTooManyPacks() throws Exception {
  39. FileBasedConfig c = repo.getConfig();
  40. c.setInt(ConfigConstants.CONFIG_GC_SECTION, null,
  41. ConfigConstants.CONFIG_KEY_AUTOPACKLIMIT, 1);
  42. c.save();
  43. SampleDataRepositoryTestCase.copyCGitTestPacks(repo);
  44. assertTrue("should find too many packs", gc.tooManyPacks());
  45. }
  46. }