Search in sources :

Example 66 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.

the class RegistryPowerShellDetectorTest method testDetectPowerShell_5.

@Test
@TestFor(issues = "TW-41000")
public void testDetectPowerShell_5() {
    m.checking(new Expectations() {

        {
            allowing(acc).readRegistryText(LOCAL_MACHINE, BIT32, "SOFTWARE\\Microsoft\\PowerShell\\3\\PowerShellEngine", "PowerShellVersion");
            will(returnValue("5.0"));
            allowing(acc).readRegistryText(LOCAL_MACHINE, BIT32, "SOFTWARE\\Microsoft\\PowerShell\\1\\PowerShellEngine", "PowerShellVersion");
            will(returnValue("2.0"));
        }
    });
    final String ver = new PowerShellRegistry(BIT32, acc).getInstalledVersion();
    assertEquals("5.0", ver);
}
Also used : Expectations(org.jmock.Expectations) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 67 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.

the class PowerShellInfoProviderTest method testSelectTool_MultipleShells.

@Test
@TestFor(issues = "TW-55922")
public void testSelectTool_MultipleShells() {
    final Map<String, String> params = new HashMap<>();
    mock64bit("6.1.0-preview.2", PowerShellEdition.CORE);
    mock64bit("6.0", PowerShellEdition.CORE);
    m.checking(new Expectations() {

        {
            allowing(myConfig).getConfigurationParameters();
            will(returnValue(params));
        }
    });
    final PowerShellInfo info = myProvider.selectTool(PowerShellBitness.x64, null, PowerShellEdition.CORE);
    assertNotNull(info);
    assertEquals("6.1.0-preview.2", info.getVersion());
}
Also used : Expectations(org.jmock.Expectations) HashMap(java.util.HashMap) PowerShellInfo(jetbrains.buildServer.powershell.agent.detect.PowerShellInfo) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 68 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.

the class PowerShellRunTypeTest method shouldProviderSemanticVersionRestriction.

@Test(dataProvider = "bitnessAndVersionProvider")
@TestFor(issues = "TW-33570")
public void shouldProviderSemanticVersionRestriction(@NotNull final PowerShellBitness bitness, @Nullable final String version) {
    final Map<String, String> parameters = createDummyParameters(bitness);
    if (version != null) {
        parameters.put(PowerShellConstants.RUNNER_MIN_VERSION, version);
    }
    final Collection<Requirement> requirements = runType.getRunnerSpecificRequirements(parameters);
    assertEquals(1, requirements.size());
    final Requirement req = requirements.iterator().next();
    assertEquals("Exists=>(powershell_Core_" + bitness.getValue() + "|powershell_Desktop_" + bitness.getValue() + ")", req.getPropertyName());
    if (version == null) {
        assertEquals(RequirementType.EXISTS, req.getType());
    } else {
        assertEquals(RequirementType.VER_NO_LESS_THAN, req.getType());
        assertEquals(version, req.getPropertyValue());
    }
}
Also used : Requirement(jetbrains.buildServer.requirements.Requirement) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 69 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-powershell by JetBrains.

the class RegistryPowerShellDetectorTest method testDetectPowerShell_ExtendedVersion.

@Test
@TestFor(issues = "TW-41000")
public void testDetectPowerShell_ExtendedVersion() {
    m.checking(new Expectations() {

        {
            allowing(acc).readRegistryText(LOCAL_MACHINE, BIT32, "SOFTWARE\\Microsoft\\PowerShell\\3\\PowerShellEngine", "PowerShellVersion");
            will(returnValue("5.0.10105"));
            allowing(acc).readRegistryText(LOCAL_MACHINE, BIT32, "SOFTWARE\\Microsoft\\PowerShell\\1\\PowerShellEngine", "PowerShellVersion");
            will(returnValue("2.0"));
        }
    });
    final String ver = new PowerShellRegistry(BIT32, acc).getInstalledVersion();
    assertEquals("5.0.10105", ver);
}
Also used : Expectations(org.jmock.Expectations) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 70 with TestFor

use of jetbrains.buildServer.util.TestFor in project teamcity-rest by JetBrains.

the class ChangeFinderTest method testChangesByBuildTypeFromDependenciesHaveDescriptor.

@Test
@TestFor(issues = "TW-72448")
public void testChangesByBuildTypeFromDependenciesHaveDescriptor() {
    final BuildTypeImpl buildConf1 = registerBuildType("buildConf1", "project");
    final BuildTypeImpl buildConf2 = registerBuildType("buildConf2", "project");
    createDependencyChain(buildConf2, buildConf1);
    MockVcsSupport vcs = new MockVcsSupport("vcs");
    vcs.setDAGBased(true);
    myFixture.getVcsManager().registerVcsSupport(vcs);
    SVcsRootEx parentRoot1 = myFixture.addVcsRoot(vcs.getName(), "", buildConf1);
    SVcsRootEx parentRoot2 = myFixture.addVcsRoot(vcs.getName(), "", buildConf2);
    VcsRootInstance root1 = buildConf1.getVcsRootInstanceForParent(parentRoot1);
    VcsRootInstance root2 = buildConf2.getVcsRootInstanceForParent(parentRoot2);
    assert root1 != null;
    assert root2 != null;
    setBranchSpec(root1, "+:*");
    setBranchSpec(root2, "+:*");
    final BuildFinderTestBase.MockCollectRepositoryChangesPolicy changesPolicy = new BuildFinderTestBase.MockCollectRepositoryChangesPolicy();
    vcs.setCollectChangesPolicy(changesPolicy);
    myFixture.addModification(modification().in(root1).version("1").parentVersions("0"));
    myFixture.addModification(modification().in(root2).version("2").parentVersions("0"));
    List<SVcsModificationOrChangeDescriptor> items = getFinder().getItems("buildType:buildConf2,changesFromDependencies:true,vcsRoot:(id:" + root1.getExternalId() + ")").myEntries;
    assertEquals("There is exactly one pending change coming from dependency.", 1, items.size());
    ChangeDescriptor descriptor = items.get(0).getChangeDescriptor();
    assertNotNull("Depency change descriptor must be present when looking for changes using build type.", descriptor);
    assertEquals(ChangeDescriptorConstants.SNAPSHOT_DEPENDENCY_VCS_CHANGE, descriptor.getType());
    SVcsModification modification = items.get(0).getSVcsModification();
    assertEquals("1", modification.getDisplayVersion());
}
Also used : MockVcsSupport(jetbrains.buildServer.serverSide.impl.MockVcsSupport) SVcsModificationOrChangeDescriptor(jetbrains.buildServer.server.rest.data.change.SVcsModificationOrChangeDescriptor) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) SVcsModificationOrChangeDescriptor(jetbrains.buildServer.server.rest.data.change.SVcsModificationOrChangeDescriptor) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

TestFor (jetbrains.buildServer.util.TestFor)129 Test (org.testng.annotations.Test)81 File (java.io.File)65 GitTestUtil.dataFile (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.dataFile)56 VcsRootImpl (jetbrains.buildServer.vcs.impl.VcsRootImpl)26 CheckoutRules (jetbrains.buildServer.vcs.CheckoutRules)21 VcsRoot (jetbrains.buildServer.vcs.VcsRoot)17 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)12 VcsException (jetbrains.buildServer.vcs.VcsException)11 URIish (org.eclipse.jgit.transport.URIish)11 Repository (org.eclipse.jgit.lib.Repository)9 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)7 AfterMethod (org.testng.annotations.AfterMethod)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 Method (java.lang.reflect.Method)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 GitTestUtil.copyRepository (jetbrains.buildServer.buildTriggers.vcs.git.tests.GitTestUtil.copyRepository)6 Build (jetbrains.buildServer.server.rest.model.build.Build)6 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)6 FileUtil.writeFile (jetbrains.buildServer.util.FileUtil.writeFile)6