Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/TagsTest.java @ 650:919418bf09a1
Fix tests: testData requires hg 1.7
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 27 Sep 2013 12:02:28 +0400 |
parents | 0b50d7952a7d |
children | 31a1aca3305c |
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial; import jetbrains.buildServer.vcs.RepositoryStateData; import jetbrains.buildServer.vcs.VcsRoot; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.File; import java.io.IOException; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.BookmarksTest.RepositoryStateDataMatcher.hasBranch; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.BookmarksTest.RepositoryStateDataMatcher.hasNoBranch; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.ServerPluginConfigBuilder.serverPluginConfig; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.not; @RequiredHgVersion(min = "1.7.0") @Test(dataProviderClass = HgVersionConstraint.class, dataProvider = "installedHgVersion") public class TagsTest extends BaseMercurialTestCase { private File myRemoteRepository; private ServerPluginConfigBuilder myConfig; @BeforeMethod public void setUp() throws Exception { super.setUp(); myConfig = serverPluginConfig() .cachesDir(myTempFiles.createTempDir()) .hgPath(Util.getHgPath()); myRemoteRepository = myTempFiles.createTempDir(); Util.copyRepository(new File("mercurial-tests/testData/tags"), myRemoteRepository); } public void no_tags_reported_by_default(HgVersion _) throws Exception { VcsRoot root = vcsRoot().withUrl(myRemoteRepository.getAbsolutePath()).build(); RepositoryStateData state = getVcs().getCollectChangesPolicy().getCurrentState(root); assertThat(state, not(hasBranch("v1").withRevision("fa7ad5b80a88"))); assertThat(state, not(hasBranch("v4").withRevision("f7fbcc489e40"))); } public void should_report_tag_revisions(HgVersion _) throws Exception { VcsRoot root = vcsRoot().withUrl(myRemoteRepository.getAbsolutePath()).withTagsEnabled(true).build(); RepositoryStateData state = getVcs().getCollectChangesPolicy().getCurrentState(root); assertThat(state, hasBranch("v1").withRevision("fa7ad5b80a88")); assertThat(state, hasBranch("v4").withRevision("f7fbcc489e40")); } public void branch_has_higher_precedence_over_tag(HgVersion _) throws Exception { VcsRoot root = vcsRoot().withUrl(myRemoteRepository.getAbsolutePath()).withTagsEnabled(true).build(); RepositoryStateData state = getVcs().getCollectChangesPolicy().getCurrentState(root); assertThat(state, hasBranch("topic").withRevision("efde33cd0b66")); } public void tags_can_be_turned_off_globally(HgVersion _) throws Exception { myConfig.withTagsAsBranches(false); VcsRoot root = vcsRoot().withUrl(myRemoteRepository.getAbsolutePath()).withTagsEnabled(true).build(); RepositoryStateData state = getVcs().getCollectChangesPolicy().getCurrentState(root); assertThat(state, not(hasBranch("v1").withRevision("fa7ad5b80a88"))); assertThat(state, not(hasBranch("v4").withRevision("f7fbcc489e40"))); } public void tags_should_not_include_tip(HgVersion _) throws Exception { VcsRoot root = vcsRoot().withUrl(myRemoteRepository.getAbsolutePath()).withTagsEnabled(true).build(); RepositoryStateData state = getVcs().getCollectChangesPolicy().getCurrentState(root); assertThat(state, hasNoBranch("tip")); } private MercurialVcsSupport getVcs() throws IOException { return mercurialSupport().withConfig(myConfig.build()).build(); } }