|
27 | 27 | import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
28 | 28 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
29 | 29 | import static org.junit.jupiter.api.Assertions.assertNull;
|
| 30 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
30 | 31 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
31 | 32 | import static org.opengrok.indexer.condition.RepositoryInstalled.Type.CVS;
|
32 | 33 | import static org.opengrok.indexer.condition.RepositoryInstalled.Type.MERCURIAL;
|
|
46 | 47 | import org.junit.jupiter.api.AfterEach;
|
47 | 48 | import org.junit.jupiter.api.BeforeAll;
|
48 | 49 | import org.junit.jupiter.api.Test;
|
| 50 | +import org.junit.jupiter.params.ParameterizedTest; |
| 51 | +import org.junit.jupiter.params.provider.ValueSource; |
49 | 52 | import org.opengrok.indexer.condition.EnabledForRepository;
|
50 | 53 | import org.opengrok.indexer.configuration.RuntimeEnvironment;
|
51 | 54 | import org.opengrok.indexer.util.FileUtilities;
|
@@ -282,9 +285,28 @@ public void testScanningDepth() throws IOException {
|
282 | 285 | }
|
283 | 286 |
|
284 | 287 | @Test
|
285 |
| - void testGetLastHistoryEntry() throws HistoryException { |
| 288 | + void testGetLastHistoryEntryNonexistent() throws HistoryException { |
286 | 289 | HistoryGuru instance = HistoryGuru.getInstance();
|
287 | 290 | File file = new File("/nonexistent");
|
288 | 291 | assertNull(instance.getLastHistoryEntry(file, true));
|
289 | 292 | }
|
| 293 | + |
| 294 | + @ParameterizedTest |
| 295 | + @ValueSource(booleans = {true, false}) |
| 296 | + void testGetLastHistoryEntry(boolean isIndexerParam) throws HistoryException { |
| 297 | + boolean isIndexer = env.isIndexer(); |
| 298 | + env.setIndexer(isIndexerParam); |
| 299 | + boolean isTagsEnabled = env.isTagsEnabled(); |
| 300 | + env.setTagsEnabled(true); |
| 301 | + HistoryGuru instance = HistoryGuru.getInstance(); |
| 302 | + File file = new File(repository.getSourceRoot(), "git"); |
| 303 | + assertTrue(file.exists()); |
| 304 | + if (isIndexerParam) { |
| 305 | + assertThrows(IllegalStateException.class, () -> instance.getLastHistoryEntry(file, true)); |
| 306 | + } else { |
| 307 | + assertNotNull(instance.getLastHistoryEntry(file, true)); |
| 308 | + } |
| 309 | + env.setIndexer(isIndexer); |
| 310 | + env.setTagsEnabled(isTagsEnabled); |
| 311 | + } |
290 | 312 | }
|
0 commit comments