view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/DagFeaturesTest.java @ 1020:a224ff290a9a

mark as node responsibilities aware
author Pavel Sher <pavel.sher@jetbrains.com>
date Wed, 22 Apr 2020 19:55:38 +0200
parents 7bf4d943d5bb
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.util.TestFor;
import jetbrains.buildServer.vcs.CheckoutRules;
import jetbrains.buildServer.vcs.ModificationData;
import jetbrains.buildServer.vcs.impl.VcsRootImpl;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.io.File;
import java.util.List;

import static jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialSupportBuilder.mercurialSupport;
import static jetbrains.buildServer.buildTriggers.vcs.mercurial.Util.copyRepository;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;

/**
 * @author dmitry.neverov
 */
@Test
public class DagFeaturesTest extends BaseMercurialTestCase {

  private MercurialVcsSupport myHg;
  private String myRepository;

  @BeforeMethod
  public void setUp() throws Exception {
    super.setUp();
    ServerPluginConfig config = new ServerPluginConfigBuilder()
            .cachesDir(myTempFiles.createTempDir())
            .build();
    myHg = mercurialSupport().withConfig(config).build();

    File original = new File("mercurial-tests/testData/rep2");
    File copy = new File(myTempFiles.createTempDir(), "rep2");
    copyRepository(original, copy);
    myRepository = copy.getAbsolutePath();
  }


  @TestFor(issues = "TW-17882")
  public void should_detect_changes_from_named_branches() throws Exception {
    VcsRootImpl root = new VcsRootBuilder().withUrl(myRepository).build();

    List<ModificationData> changes = myHg.getCollectChangesPolicy().collectChanges(root, "8:b6e2d176fe8e", "12:1e620196c4b6", CheckoutRules.DEFAULT);
    assertEquals(4, changes.size());
    for (ModificationData change : changes) {
      assertFalse(change.getParentRevisions().isEmpty());
    }

    changes = myHg.getCollectChangesPolicy().collectChanges(root, "12:1e620196c4b6", "18:df04faa7575a", CheckoutRules.DEFAULT);
    assertEquals(6, changes.size());
    for (ModificationData change : changes) {
      assertFalse(change.getParentRevisions().isEmpty());
    }
  }


  @TestFor(issues = "TW-17882")
  public void should_report_changes_only_from_merged_named_branches() throws Exception {
    VcsRootImpl root = new VcsRootBuilder().withUrl(myRepository).build();
    List<ModificationData> changes = myHg.getCollectChangesPolicy().collectChanges(root, "1e620196c4b6", "505c5b9d01e6", CheckoutRules.DEFAULT);
    assertEquals(2, changes.size());
  }
}