# HG changeset patch # User Dmitry Neverov # Date 1302073288 -14400 # Node ID e07386542f69dfef48f38865392f4fc8e5d50dc3 # Parent ec4c31d0eec084cfc6ece83050490f14dd9387c7 Add test for identify command diff -r ec4c31d0eec0 -r e07386542f69 mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java Wed Apr 06 11:01:28 2011 +0400 @@ -0,0 +1,48 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; + +import jetbrains.buildServer.vcs.VcsException; +import org.jetbrains.annotations.NotNull; +import org.testng.annotations.Test; + +import java.io.IOException; + +/** + * @author dmitry.neverov + */ +@Test +public class IdentifyCommandTest extends BaseCommandTestCase { + + public void should_throw_exception_if_cset_is_not_present() throws IOException { + setRepository("mercurial-tests/testData/rep1", true); + String nonExistingVersion = "1d446e82d355"; + try { + runIdentify(new ChangeSet(nonExistingVersion)); + fail("Should throw exception for non-existing change set"); + } catch (VcsException e) { + assertTrue(true); + } + } + + public void should_not_throw_exception_if_cset_is_present() throws IOException { + setRepository("mercurial-tests/testData/rep1", true); + String nonExistingVersion = "1d446e82d356"; + try { + runIdentify(new ChangeSet(nonExistingVersion)); + } catch (VcsException e) { + fail("Should not throw an exception if change set is present"); + } + } + + private Void runIdentify(final ChangeSet cset) throws IOException, VcsException { + return runCommand(new CommandExecutor() { + public Void execute(@NotNull final Settings settings) throws VcsException { + IdentifyCommand identify = new IdentifyCommand(settings); + identify.setWorkingDir(settings.getLocalRepositoryDir()); + identify.setInLocalRepository(true); + identify.setChangeSet(cset); + identify.execute(); + return null; + } + }); + } +}