view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgRepoTest.java @ 888:207c4ec46d54

CommitSupport: return CommitResult instead of revision
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Mon, 03 Nov 2014 12:53:47 +0100
parents 31a1aca3305c
children 2a8670c6afa9 38adef4f1b8f
line wrap: on
line source
/*
 * Copyright 2000-2014 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 com.intellij.openapi.diagnostic.Logger;
import jetbrains.buildServer.TempFiles;
import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.AuthSettings;
import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.TestCommandSettingsFactory;
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.assertEquals;
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;

@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());
  }

}