]> source.dussan.org Git - jgit.git/commitdiff
Improve test coverage when core.trustPackedRefsStat set to after_open 04/200304/1
authorPrudhvi Akhil Alahari <quic_prudhvi@quicinc.com>
Thu, 2 Mar 2023 11:21:48 +0000 (16:51 +0530)
committerPrudhvi Akhil Alahari <quic_prudhvi@quicinc.com>
Thu, 2 Mar 2023 15:50:02 +0000 (21:20 +0530)
As of today, we don't have test coverage for RefDirectory when
core.trustPackedRefsStat config is set to after_open. Thus create new
test classes which set core.trustPackedRefsStat config to after_open in
setup and extend RefDirectoryTest and FileRepositoryBuilderTest
respectively.

Change-Id: I1db6fcf414bc488106ad4c85fb934480f299c995
Signed-off-by: Prudhvi Akhil Alahari <quic_prudhvi@quicinc.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderAfterOpenConfigTest.java [new file with mode: 0644]
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryAfterOpenConfigTest.java [new file with mode: 0644]
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryTest.java

diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderAfterOpenConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderAfterOpenConfigTest.java
new file mode 100644 (file)
index 0000000..100bd32
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc.
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.internal.storage.file;
+
+import org.eclipse.jgit.lib.ConfigConstants;
+import org.eclipse.jgit.lib.CoreConfig;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.util.SystemReader;
+import org.junit.Before;
+
+public class FileRepositoryBuilderAfterOpenConfigTest extends FileRepositoryBuilderTest {
+       /** {@inheritDoc} */
+       @Before
+       @Override
+       public void setUp() throws Exception {
+               super.setUp();
+               StoredConfig userConfig = SystemReader.getInstance().getUserConfig();
+               userConfig.setEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
+                               ConfigConstants.CONFIG_KEY_TRUST_PACKED_REFS_STAT,
+                               CoreConfig.TrustPackedRefsStat.AFTER_OPEN);
+               userConfig.save();
+       }
+}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryAfterOpenConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefDirectoryAfterOpenConfigTest.java
new file mode 100644 (file)
index 0000000..42304e2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc.
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.internal.storage.file;
+
+import org.eclipse.jgit.lib.ConfigConstants;
+import org.eclipse.jgit.lib.CoreConfig;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.util.SystemReader;
+
+public class RefDirectoryAfterOpenConfigTest extends RefDirectoryTest {
+       /** {@inheritDoc} */
+       @Override
+       public void refDirectorySetup() throws Exception {
+               StoredConfig userConfig = SystemReader.getInstance().getUserConfig();
+               userConfig.setEnum(ConfigConstants.CONFIG_CORE_SECTION, null,
+                               ConfigConstants.CONFIG_KEY_TRUST_PACKED_REFS_STAT,
+                               CoreConfig.TrustPackedRefsStat.AFTER_OPEN);
+               userConfig.save();
+               super.refDirectorySetup();
+       }
+}
index 38c545ef576678dc7bc4260f4197d5f7e5fa7272..4b80f1897020eca95a6c16a1d25aea69b568f7e1 100644 (file)
@@ -72,7 +72,10 @@ public class RefDirectoryTest extends LocalDiskRepositoryTestCase {
        @Before
        public void setUp() throws Exception {
                super.setUp();
+               refDirectorySetup();
+       }
 
+       public void refDirectorySetup() throws Exception {
                diskRepo = createBareRepository();
                refdir = (RefDirectory) diskRepo.getRefDatabase();