summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorTomasz Zarna <tzarna@gmail.com>2012-12-07 22:45:01 +0100
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2013-01-06 19:12:10 -0500
commitc98abc9c0586c73ef7df4172644b7dd21c979e9d (patch)
tree9a99c1f204cd96dab78f1b427de6f4f30ecbe183 /org.eclipse.jgit.test
parentc2d1183e39174336605509642b6f60157b9e2c3a (diff)
downloadjgit-c98abc9c0586c73ef7df4172644b7dd21c979e9d.tar.gz
jgit-c98abc9c0586c73ef7df4172644b7dd21c979e9d.zip
Add additional FastForwardMode enums for different config contexts
FastForwardMode should be represented by different enums depending on context it is set or get from. E.g. FastForwardMode.FF_ONLY for branch.<name>.mergeoptions is "--ff-only" but for merge.ff it is "only". Change-Id: I3ecc16d48e715b81320b73ffae4caf3558f965f2
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java79
1 files changed, 77 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
index e675609290..f02012eb5a 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
@@ -63,6 +63,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
+import org.eclipse.jgit.api.MergeCommand.FastForwardMode;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.util.FS;
@@ -287,7 +288,7 @@ public class ConfigTest {
assertSame(CoreConfig.AutoCRLF.FALSE, c.getEnum("s", null, "d",
CoreConfig.AutoCRLF.FALSE));
- c = parse("[s \"b\"]\n\tc = one two\n");
+ c = parse("[s \"b\"]\n\tc = one-two\n");
assertSame(TestEnum.ONE_TWO, c.getEnum("s", "b", "c", TestEnum.ONE_TWO));
}
@@ -295,7 +296,81 @@ public class ConfigTest {
public void testSetEnum() {
final Config c = new Config();
c.setEnum("s", "b", "c", TestEnum.ONE_TWO);
- assertEquals("[s \"b\"]\n\tc = one two\n", c.toText());
+ assertEquals("[s \"b\"]\n\tc = one-two\n", c.toText());
+ }
+
+ @Test
+ public void testGetFastForwardMergeoptions() throws ConfigInvalidException {
+ Config c = new Config(null); // not set
+ assertSame(FastForwardMode.MergeOptions.__FF, c.getEnum(
+ ConfigConstants.CONFIG_BRANCH_SECTION, "side",
+ ConfigConstants.CONFIG_KEY_MERGEOPTIONS,
+ FastForwardMode.MergeOptions.__FF));
+ c = parse("[branch \"side\"]\n\tmergeoptions = --ff-only\n");
+ assertSame(FastForwardMode.MergeOptions.__FF_ONLY, c.getEnum(
+ ConfigConstants.CONFIG_BRANCH_SECTION, "side",
+ ConfigConstants.CONFIG_KEY_MERGEOPTIONS,
+ FastForwardMode.MergeOptions.__FF_ONLY));
+ c = parse("[branch \"side\"]\n\tmergeoptions = --ff\n");
+ assertSame(FastForwardMode.MergeOptions.__FF, c.getEnum(
+ ConfigConstants.CONFIG_BRANCH_SECTION, "side",
+ ConfigConstants.CONFIG_KEY_MERGEOPTIONS,
+ FastForwardMode.MergeOptions.__FF));
+ c = parse("[branch \"side\"]\n\tmergeoptions = --no-ff\n");
+ assertSame(FastForwardMode.MergeOptions.__NO_FF, c.getEnum(
+ ConfigConstants.CONFIG_BRANCH_SECTION, "side",
+ ConfigConstants.CONFIG_KEY_MERGEOPTIONS,
+ FastForwardMode.MergeOptions.__NO_FF));
+ }
+
+ @Test
+ public void testSetFastForwardMergeoptions() {
+ final Config c = new Config();
+ c.setEnum("branch", "side", "mergeoptions",
+ FastForwardMode.MergeOptions.valueOf(FastForwardMode.FF));
+ assertEquals("[branch \"side\"]\n\tmergeoptions = --ff\n", c.toText());
+ c.setEnum("branch", "side", "mergeoptions",
+ FastForwardMode.MergeOptions.valueOf(FastForwardMode.FF_ONLY));
+ assertEquals("[branch \"side\"]\n\tmergeoptions = --ff-only\n",
+ c.toText());
+ c.setEnum("branch", "side", "mergeoptions",
+ FastForwardMode.MergeOptions.valueOf(FastForwardMode.NO_FF));
+ assertEquals("[branch \"side\"]\n\tmergeoptions = --no-ff\n",
+ c.toText());
+ }
+
+ @Test
+ public void testGetFastForwardMerge() throws ConfigInvalidException {
+ Config c = new Config(null); // not set
+ assertSame(FastForwardMode.Merge.TRUE, c.getEnum(
+ ConfigConstants.CONFIG_KEY_MERGE, null,
+ ConfigConstants.CONFIG_KEY_FF, FastForwardMode.Merge.TRUE));
+ c = parse("[merge]\n\tff = only\n");
+ assertSame(FastForwardMode.Merge.ONLY, c.getEnum(
+ ConfigConstants.CONFIG_KEY_MERGE, null,
+ ConfigConstants.CONFIG_KEY_FF, FastForwardMode.Merge.ONLY));
+ c = parse("[merge]\n\tff = true\n");
+ assertSame(FastForwardMode.Merge.TRUE, c.getEnum(
+ ConfigConstants.CONFIG_KEY_MERGE, null,
+ ConfigConstants.CONFIG_KEY_FF, FastForwardMode.Merge.TRUE));
+ c = parse("[merge]\n\tff = false\n");
+ assertSame(FastForwardMode.Merge.FALSE, c.getEnum(
+ ConfigConstants.CONFIG_KEY_MERGE, null,
+ ConfigConstants.CONFIG_KEY_FF, FastForwardMode.Merge.FALSE));
+ }
+
+ @Test
+ public void testSetFastForwardMerge() {
+ final Config c = new Config();
+ c.setEnum("merge", null, "ff", FastForwardMode.Merge.valueOf(FastForwardMode.FF));
+ assertEquals("[merge]\n\tff = true\n", c.toText());
+ c.setEnum("merge", null, "ff",
+ FastForwardMode.Merge.valueOf(FastForwardMode.FF_ONLY));
+ assertEquals("[merge]\n\tff = only\n",
+ c.toText());
+ c.setEnum("merge", null, "ff",
+ FastForwardMode.Merge.valueOf(FastForwardMode.NO_FF));
+ assertEquals("[merge]\n\tff = false\n", c.toText());
}
@Test