Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/TagsTest.java @ 649:0b50d7952a7d
TW-23468 support tags as branches
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Thu, 26 Sep 2013 16:28:57 +0400 |
parents | |
children | 919418bf09a1 |
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; @Test 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() 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() 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() 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() 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() 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(); } }