Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepoTest.java @ 982:4a0ea921c214 Indore-2017.2.x
Merge back changes since 28.04.2017
author | Dmitry Neverov <dmitry.neverov@gmail.com> |
---|---|
date | Wed, 24 Jan 2018 22:02:52 +0100 |
parents | 7bf4d943d5bb 38adef4f1b8f |
children |
line wrap: on
line source
/* * Copyright 2000-2018 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.buildTriggers.vcs.mercurial; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory; import jetbrains.buildServer.util.TestFor; import jetbrains.buildServer.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.io.File; import java.util.List; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository; import static org.testng.AssertJUnit.*; @Test public class HgRepoTest extends BaseMercurialTestCase { public void subrepos() throws Exception { File repository = myTempFiles.createTempDir(); copyRepository(new File("mercurial-tests/testData/subrepos/r1"), repository); HgRepo repo = new HgRepo(new TestCommandSettingsFactory(), repository, Util.getHgPath(), new AuthSettings()); List<HgSubrepoConfigChange> changes = repo.getSubrepoConfigChanges("09c256b6163e"); assertEquals(1, changes.size()); HgSubrepoConfigChange c = changes.get(0); assertEquals("r2", c.getPath()); //noinspection ConstantConditions assertTrue(c.getPrevious().get(0).revision().startsWith("9e4a2fef1a1c")); //noinspection ConstantConditions assertTrue(c.getCurrent().revision().startsWith("ebb884b1b691")); changes = repo.getSubrepoConfigChanges("4d7b3db8779f"); assertEquals(1, changes.size()); c = changes.get(0); assertEquals("r2", c.getPath()); //noinspection ConstantConditions assertTrue(c.getPrevious().get(0).revision().startsWith("916933c1dd8e")); assertNull(c.getCurrent()); changes = repo.getSubrepoConfigChanges("d350e7209906"); assertEquals(1, changes.size()); } @DataProvider(name = "urlsWithNewLines") public static Object[][] urlsWithNewLines() { return new Object[][] { new Object[] { "http://some.org/repo\n" }, new Object[] { "http://some.org/repo\r" }, new Object[] { "http://some.org/repo\n[section]" }, new Object[] { "http://some.org/repo\r[section]" }, new Object[] { "http://some.org/repo\r\n[section]" }, }; } @TestFor(issues = "TW-50043")//TW-50043 is about git, but hg suffers from the same problem @Test(dataProvider = "urlsWithNewLines") public void newline_in_url(@NotNull String url) throws Exception { File repository = myTempFiles.createTempDir(); HgRepo repo = new HgRepo(new TestCommandSettingsFactory(), repository, Util.getHgPath(), new AuthSettings()); repo.init().call(); try { repo.setDefaultPath(url); fail("no error for url '" + url + "'"); } catch (VcsException e) { //expected } } }