Mercurial > hg > mercurial
changeset 217:e07386542f69 Eluru-6.0.x
Add test for identify command
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Wed, 06 Apr 2011 11:01:28 +0400 |
parents | ec4c31d0eec0 |
children | ae0d53fe26f2 |
files | mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommandTest.java |
diffstat | 1 files changed, 48 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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<Void>() { + 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; + } + }); + } +}