Skip to content

Commit

Permalink
closes 4468
Browse files Browse the repository at this point in the history
Signed-off-by: Gino Augustine <[email protected]>
  • Loading branch information
ginoaugustine authored and vladak committed Nov 3, 2023
1 parent b996a17 commit 0435f18
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
9 changes: 4 additions & 5 deletions opengrok-web/src/main/java/org/opengrok/web/PageConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,11 @@ private void generatePlainTextDiffData(DiffData data, String[] filepath) {
.forEach(IOUtils::close);
}
if (Objects.isNull(data.errorMsg)) {
return;
populateRevisionData(data);
populateRevisionURLDetails(data, filepath);
data.full = fullDiff();
data.type = getDiffType();
}
populateRevisionData(data);
populateRevisionURLDetails(data, filepath);
data.full = fullDiff();
data.type = getDiffType();
}

private void populateGenreIfEmpty(DiffData data, InputStream[] inArray) {
Expand Down
17 changes: 14 additions & 3 deletions opengrok-web/src/test/java/org/opengrok/web/DiffTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.opengrok.indexer.configuration.RuntimeEnvironment;
import org.opengrok.indexer.history.HistoryGuru;
import org.opengrok.indexer.history.RepositoryFactory;
import org.opengrok.indexer.index.Indexer;
import org.opengrok.indexer.util.TestRepository;
import org.opengrok.indexer.web.QueryParameters;

import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -50,7 +50,7 @@ class DiffTest {
@BeforeAll
static void setUp() throws Exception {
repository = new TestRepository();
repository.create(HistoryGuru.class.getResource("/repositories"));
repository.create(DiffTest.class.getResource("/repositories"));

env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
Expand Down Expand Up @@ -98,6 +98,12 @@ void testGetDiffDataInvalidRevision() {
assertNotNull(diffData);
assertNotNull(diffData.getErrorMsg());
assertTrue(diffData.getErrorMsg().startsWith("Unable to get revision"));
assertAll(
() -> assertNull(diffData.getRevision()),
() -> assertNull(diffData.getParam(0)),
() -> assertNull(diffData.getParam(1)),
() -> assertNull(diffData.getType())
);
}

@Test
Expand All @@ -119,7 +125,12 @@ void testGetDiffData() {
assertAll(() -> assertEquals(rev1, diffData.getRev(0)),
() -> assertEquals(rev2, diffData.getRev(1)),
() -> assertTrue(diffData.getFile(0).length > 0),
() -> assertTrue(diffData.getFile(1).length > 0)
() -> assertTrue(diffData.getFile(1).length > 0),
() -> assertNotNull(diffData.getRevision()),
() -> assertEquals("/git/main.c@bb74b7e", diffData.getParam(0)),
() -> assertEquals("/git/main.c@aa35c25", diffData.getParam(1)),
() -> assertEquals(DiffType.SIDEBYSIDE, diffData.getType()),
() -> assertFalse(diffData.isFull())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.opengrok.indexer.configuration.Project;
import org.opengrok.indexer.configuration.RuntimeEnvironment;
import org.opengrok.indexer.history.Annotation;
import org.opengrok.indexer.history.HistoryGuru;
import org.opengrok.indexer.history.LatestRevisionUtil;
import org.opengrok.indexer.history.RepositoryFactory;
import org.opengrok.indexer.index.Indexer;
Expand Down Expand Up @@ -77,7 +76,7 @@ class PageConfigTest {
@BeforeAll
public static void setUpClass() throws Exception {
repository = new TestRepository();
repository.create(HistoryGuru.class.getResource("/repositories"));
repository.create(PageConfigTest.class.getResource("/repositories"));
RuntimeEnvironment.getInstance().setRepositories(repository.getSourceRoot());
}

Expand Down

0 comments on commit 0435f18

Please sign in to comment.