diff test/org/tmatesoft/hg/test/TestStatus.java @ 68:0e499fed9b3d

StatusCommand with tests. Extra constants to indicate common revision cases
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 22 Jan 2011 22:11:24 +0100
parents 52dc3f4cfc76
children 6f1b88693d48
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestStatus.java	Fri Jan 21 19:21:43 2011 +0100
+++ b/test/org/tmatesoft/hg/test/TestStatus.java	Sat Jan 22 22:11:24 2011 +0100
@@ -16,11 +16,15 @@
  */
 package org.tmatesoft.hg.test;
 
+import static com.tmate.hgkit.ll.HgRepository.TIP;
+
 import java.io.File;
 import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.tmatesoft.hg.core.StatusCommand;
+
 import com.tmate.hgkit.fs.FileWalker;
 import com.tmate.hgkit.fs.RepositoryLookup;
 import com.tmate.hgkit.ll.HgRepository;
@@ -34,9 +38,9 @@
  */
 public class TestStatus {
 
+	private final HgRepository repo;
 	private StatusOutputParser statusParser;
 	private ExecHelper eh;
-	private final HgRepository repo;
 
 	public static void main(String[] args) throws Exception {
 		HgRepository repo = new RepositoryLookup().detectFromWorkingDir();
@@ -53,6 +57,7 @@
 	
 	public void testLowLevel() throws Exception {
 		final WorkingCopyStatusCollector wcc = new WorkingCopyStatusCollector(repo, new FileWalker(new File(System.getProperty("user.dir"))));
+		statusParser.reset();
 		eh.run("hg", "status", "-A");
 		StatusCollector.Record r = wcc.status(HgRepository.TIP);
 		report("hg status -A", r, statusParser);
@@ -71,7 +76,25 @@
 	}
 	
 	public void testStatusCommand() throws Exception {
-		throw HgRepository.notImplemented();
+		final StatusCommand sc = new StatusCommand(repo).all();
+		StatusCollector.Record r;
+		statusParser.reset();
+		eh.run("hg", "status", "-A");
+		sc.execute(r = new StatusCollector.Record());
+		report("hg status -A", r, statusParser);
+		//
+		statusParser.reset();
+		int revision = 3;
+		eh.run("hg", "status", "-A", "--rev", String.valueOf(revision));
+		sc.base(revision).execute(r = new StatusCollector.Record());
+		report("status -A --rev " + revision, r, statusParser);
+		//
+		statusParser.reset();
+		eh.run("hg", "status", "-A", "--change", String.valueOf(revision));
+		sc.base(TIP).revision(revision).execute(r = new StatusCollector.Record());
+		report("status -A --change " + revision, r, statusParser);
+		
+		// TODO check not -A, but defaults()/custom set of modifications 
 	}
 	
 	private static void report(String what, StatusCollector.Record r, StatusOutputParser statusParser) {