Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java
index a131e5e63b..93f47090a3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleAddTest.java
@@ -161,6 +161,7 @@ public class SubmoduleAddTest extends RepositoryTestCase {
DirCacheEditor editor = cache.editor();
editor.add(new PathEdit(path) {
+ @Override
public void apply(DirCacheEntry ent) {
ent.setFileMode(FileMode.GITLINK);
ent.setObjectId(id);
@@ -182,6 +183,37 @@ public class SubmoduleAddTest extends RepositoryTestCase {
}
@Test
+ public void addSubmoduleWithInvalidPath() throws Exception {
+ SubmoduleAddCommand command = new SubmoduleAddCommand(db);
+ command.setPath("-invalid-path");
+ // TODO(ms) set name to a valid value in 5.1.0 and adapt expected
+ // message below
+ command.setURI("http://example.com/repo/x.git");
+ try {
+ command.call().close();
+ fail("Exception not thrown");
+ } catch (IllegalArgumentException e) {
+ // TODO(ms) should check for submodule path, but can't set name
+ // before 5.1.0
+ assertEquals("Invalid submodule name '-invalid-path'",
+ e.getMessage());
+ }
+ }
+
+ @Test
+ public void addSubmoduleWithInvalidUri() throws Exception {
+ SubmoduleAddCommand command = new SubmoduleAddCommand(db);
+ command.setPath("valid-path");
+ command.setURI("-upstream");
+ try {
+ command.call().close();
+ fail("Exception not thrown");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Invalid submodule URL '-upstream'", e.getMessage());
+ }
+ }
+
+ @Test
public void addSubmoduleWithRelativeUri() throws Exception {
try (Git git = new Git(db)) {
writeTrashFile("file.txt", "content");
@@ -268,4 +300,4 @@ public class SubmoduleAddTest extends RepositoryTestCase {
ConfigConstants.CONFIG_KEY_URL));
}
}
-} \ No newline at end of file
+}

Back to the top