diff --git a/scm-plugins/scm-hg-plugin/src/test/java/sonia/scm/repository/spi/HgBrowseCommandTest.java b/scm-plugins/scm-hg-plugin/src/test/java/sonia/scm/repository/spi/HgBrowseCommandTest.java index bf34a0ad92..c017d0632c 100644 --- a/scm-plugins/scm-hg-plugin/src/test/java/sonia/scm/repository/spi/HgBrowseCommandTest.java +++ b/scm-plugins/scm-hg-plugin/src/test/java/sonia/scm/repository/spi/HgBrowseCommandTest.java @@ -209,6 +209,76 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase { assertThat(root.isTruncated()).isFalse(); } + + @Test + public void testRecursiveLimit() throws IOException { + BrowseCommandRequest request = new BrowseCommandRequest(); + + request.setLimit(4); + request.setRecursive(true); + + FileObject root = new HgBrowseCommand(cmdContext, repository).getBrowserResult(request).getFile(); + + Collection foList = root.getChildren(); + + assertThat(foList) + .extracting("name") + .containsExactly("c", "a.txt"); + + FileObject c = getFileObject(foList, "c"); + + Collection cChildren = c.getChildren(); + assertThat(cChildren) + .extracting("name") + .containsExactly("d.txt", "e.txt"); + } + + @Test + public void testRecursiveLimitInSubDir() throws IOException { + BrowseCommandRequest request = new BrowseCommandRequest(); + + request.setLimit(2); + request.setRecursive(true); + + FileObject root = new HgBrowseCommand(cmdContext, repository).getBrowserResult(request).getFile(); + + Collection foList = root.getChildren(); + + assertThat(foList) + .extracting("name") + .containsExactly("c"); + + FileObject c = getFileObject(foList, "c"); + + Collection cChildren = c.getChildren(); + assertThat(cChildren) + .extracting("name") + .containsExactly("d.txt"); + } + + @Test + public void testRecursiveOffset() throws IOException { + BrowseCommandRequest request = new BrowseCommandRequest(); + + request.setOffset(2); + request.setRecursive(true); + + FileObject root = new HgBrowseCommand(cmdContext, repository).getBrowserResult(request).getFile(); + + Collection foList = root.getChildren(); + + assertThat(foList) + .extracting("name") + .containsExactly("c", "a.txt", "b.txt", "f.txt"); + + FileObject c = getFileObject(foList, "c"); + + Collection cChildren = c.getChildren(); + assertThat(cChildren) + .extracting("name") + .containsExactly("e.txt"); + } + //~--- get methods ---------------------------------------------------------- /**