Hacktoberfest - [JENKINS-62446]Test coverage for tool.maven and tool.mavenGlobalConfig (#1525)

* [JENKINS-62446] Test coverage for tool.maven and tool.mavenGlobalConfig

* Adding todo linked to upstream PR.

Co-authored-by: aHenryJard <ajard@cloudbees.com>
This commit is contained in:
A. Jard 2020-11-03 14:18:15 +01:00 committed by GitHub
parent ebee63be35
commit b957c97cc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,43 @@
package io.jenkins.plugins.casc;
import hudson.ExtensionList;
import hudson.tasks.Maven;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
import jenkins.model.Jenkins;
import jenkins.mvn.GlobalMavenConfig;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
public class GlobalToolGlobalMavenTest {
@Rule
public JenkinsConfiguredWithCodeRule j = new JenkinsConfiguredWithCodeRule();
@Issue("JENKINS-62446")
@Test
@ConfiguredWithCode("GlobalToolGlobalMavenTest.yaml")
public void mavenGlobalConfigurationShouldBeConfigurable() {
final Jenkins jenkins = Jenkins.get();
//The one with @Symbol("maven")
ExtensionList<Maven.DescriptorImpl> mavenTool = jenkins
.getExtensionList(Maven.DescriptorImpl.class);
assertThat("An installation with 'custom' name should have been configured.",
mavenTool.get(0).getInstallations()[0].getName(), is("custom"));
//The one with @Symbol("mavenGlobalConfig") since TODO
ExtensionList<GlobalMavenConfig> globalMavenConfig = jenkins
.getExtensionList(GlobalMavenConfig.class);
//TODO when https://github.com/jenkinsci/jenkins/pull/5008 is merged and released
// uncomment the mavenGlobalConfig in the GlobalToolGlobalMavenTest.yaml file and add assertions on configuration
// update the since comment above with Jenkins version
}
}

View File

@ -0,0 +1,18 @@
tool:
maven:
installations:
- name: "custom"
properties:
- installSource:
installers:
- maven:
id: "3.6.3"
# TODO when https://github.com/jenkinsci/jenkins/pull/5008 is merged and released
# uncomment below and update test
#mavenGlobalConfig:
# globalSettingsProvider:
# filePath:
# path: "/tmp2/.m2"
# settingsProvider:
# filePath:
# path: "/tmp2/settings.xml"