changeset 286:954763c82cc3

Few tests for working copy information (branch, parents)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 03 Sep 2011 22:06:16 +0200
parents 6dbbc53fc46d
children ed6b74a58c66
files build.xml test/org/tmatesoft/hg/test/TestDirstate.java
diffstat 2 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/build.xml	Sat Sep 03 21:46:13 2011 +0200
+++ b/build.xml	Sat Sep 03 22:06:16 2011 +0200
@@ -86,6 +86,7 @@
 			<test name="org.tmatesoft.hg.test.TestStatus" />
 			<test name="org.tmatesoft.hg.test.TestStorePath" />
 			<test name="org.tmatesoft.hg.test.TestIgnore" />
+			<test name="org.tmatesoft.hg.test.TestDirstate" />
 			<test name="org.tmatesoft.hg.test.TestByteChannel" />
 			<test name="org.tmatesoft.hg.test.TestClone" />
 			<test name="org.tmatesoft.hg.test.TestIncoming" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/org/tmatesoft/hg/test/TestDirstate.java	Sat Sep 03 22:06:16 2011 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011 TMate Software Ltd
+ *  
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * For information on how to redistribute this software under
+ * the terms of a license other than GNU General Public License
+ * contact TMate Software at support@hg4j.com
+ */
+package org.tmatesoft.hg.test;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.tmatesoft.hg.core.Nodeid;
+import org.tmatesoft.hg.repo.HgLookup;
+import org.tmatesoft.hg.repo.HgRepository;
+import org.tmatesoft.hg.util.Pair;
+
+/**
+ *
+ * @author Artem Tikhomirov
+ * @author TMate Software Ltd.
+ */
+public class TestDirstate {
+	private HgRepository repo;
+
+	@Test
+	public void testParents() throws Exception {
+		repo = Configuration.get().find("log-branches");
+		final Pair<Nodeid, Nodeid> wcParents = repo.getWorkingCopyParents();
+		Assert.assertEquals("5f24ef64e9dfb1540db524f88cb5c3d265e1a3b5", wcParents.first().toString());
+		Assert.assertTrue(wcParents.second().isNull());
+		//
+		// TODO same static and non-static
+	}
+
+	@Test
+	public void testParentsEmptyRepo() throws Exception {
+		// check contract return values for empty/nonexistent dirstate
+		repo = new HgLookup().detect(TestIncoming.initEmptyTempRepo("testParentsEmptyRepo"));
+		final Pair<Nodeid, Nodeid> wcParents = repo.getWorkingCopyParents();
+		Assert.assertTrue(wcParents.first().isNull());
+		Assert.assertTrue(wcParents.second().isNull());
+	}
+
+	@Test
+	public void testBranchName() throws Exception {
+		repo = Configuration.get().find("log-branches");
+		Assert.assertEquals("test", repo.getWorkingCopyBranchName());
+		repo = Configuration.get().own();
+		Assert.assertEquals("default", repo.getWorkingCopyBranchName());
+	}
+}