Search in sources :

Example 1 with NodeJSInstallation

use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project configuration-as-code-plugin by jenkinsci.

the class NodeJSTest method configure_nodejs.

@Test
@ConfiguredWithReadme("nodejs/README.md")
public void configure_nodejs() {
    final NodeJSInstallation.DescriptorImpl descriptor = ExtensionList.lookupSingleton(NodeJSInstallation.DescriptorImpl.class);
    assertEquals(1, descriptor.getInstallations().length);
    final NodeJSInstallation nodejs = descriptor.getInstallations()[0];
    final InstallSourceProperty installSourceProperty = nodejs.getProperties().get(InstallSourceProperty.class);
    final NodeJSInstaller nodeJSInstaller = installSourceProperty.installers.get(NodeJSInstaller.class);
    assertEquals("12.11.1", nodeJSInstaller.id);
    assertEquals(48, nodeJSInstaller.getNpmPackagesRefreshHours().longValue());
}
Also used : NodeJSInstallation(jenkins.plugins.nodejs.tools.NodeJSInstallation) InstallSourceProperty(hudson.tools.InstallSourceProperty) NodeJSInstaller(jenkins.plugins.nodejs.tools.NodeJSInstaller) Test(org.junit.Test) ConfiguredWithReadme(io.jenkins.plugins.casc.misc.ConfiguredWithReadme)

Example 2 with NodeJSInstallation

use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project nodejs-plugin by jenkinsci.

the class NodeJSBuildWrapperTest method test_calls_sequence_of_installer.

@Test
public void test_calls_sequence_of_installer() throws Exception {
    FreeStyleProject job = j.createFreeStyleProject("free");
    NodeJSInstallation installation = mockInstaller();
    NodeJSBuildWrapper bw = mockWrapper(installation, mock(NPMConfig.class));
    job.getBuildWrappersList().add(bw);
    j.assertBuildStatusSuccess(job.scheduleBuild2(0));
    verify(installation).forNode(any(Node.class), any(TaskListener.class));
    verify(installation).forEnvironment(any(EnvVars.class));
    verify(installation).buildEnvVars(any(EnvVars.class));
}
Also used : NodeJSInstallation(jenkins.plugins.nodejs.tools.NodeJSInstallation) NPMConfig(jenkins.plugins.nodejs.configfiles.NPMConfig) EnvVars(hudson.EnvVars) Node(hudson.model.Node) TaskListener(hudson.model.TaskListener) FreeStyleProject(hudson.model.FreeStyleProject) Test(org.junit.Test)

Example 3 with NodeJSInstallation

use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project nodejs-plugin by jenkinsci.

the class NodeJSBuildWrapperTest method test_check_no_executable_in_installation_folder.

@Issue("JENKINS-45840")
@Test
public void test_check_no_executable_in_installation_folder() throws Exception {
    FreeStyleProject job = j.createFreeStyleProject("free");
    NodeJSInstallation installation = mockInstaller();
    when(installation.getExecutable(any(Launcher.class))).thenReturn(null);
    NodeJSBuildWrapper bw = mockWrapper(installation, mock(NPMConfig.class));
    job.getBuildWrappersList().add(bw);
    j.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0));
}
Also used : NodeJSInstallation(jenkins.plugins.nodejs.tools.NodeJSInstallation) NPMConfig(jenkins.plugins.nodejs.configfiles.NPMConfig) Launcher(hudson.Launcher) FreeStyleProject(hudson.model.FreeStyleProject) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 4 with NodeJSInstallation

use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project nodejs-plugin by jenkinsci.

the class NodeJSCommandInterpreterTest method test_set_of_cache_location.

@Test
public void test_set_of_cache_location() throws Exception {
    final File cacheFolder = folder.newFolder();
    NodeJSInstallation installation = mockInstaller();
    NodeJSCommandInterpreter builder = CIBuilderHelper.createMock("test_creation_of_config", installation);
    builder.setCacheLocationStrategy(new TestCacheLocationLocator(cacheFolder));
    FreeStyleProject job = j.createFreeStyleProject("cache");
    job.getBuildersList().add(builder);
    job.getBuildersList().add(new EnvVarVerifier(NodeJSConstants.NPM_CACHE_LOCATION, cacheFolder.getAbsolutePath()));
    j.assertBuildStatusSuccess(job.scheduleBuild2(0));
}
Also used : NodeJSInstallation(jenkins.plugins.nodejs.tools.NodeJSInstallation) EnvVarVerifier(jenkins.plugins.nodejs.VerifyEnvVariableBuilder.EnvVarVerifier) FreeStyleProject(hudson.model.FreeStyleProject) File(java.io.File) Test(org.junit.Test)

Example 5 with NodeJSInstallation

use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project nodejs-plugin by jenkinsci.

the class NodeJSCommandInterpreterTest method test_check_no_executable_in_installation_folder.

@Issue("JENKINS-45840")
@Test
public void test_check_no_executable_in_installation_folder() throws Exception {
    NodeJSInstallation installation = mockInstaller();
    when(installation.getExecutable(any(Launcher.class))).thenReturn(null);
    NodeJSCommandInterpreter builder = CIBuilderHelper.createMock("test_creation_of_config", installation, null);
    FreeStyleProject job = j.createFreeStyleProject("free");
    job.getBuildersList().add(builder);
    j.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0));
}
Also used : NodeJSInstallation(jenkins.plugins.nodejs.tools.NodeJSInstallation) Launcher(hudson.Launcher) FreeStyleProject(hudson.model.FreeStyleProject) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Aggregations

NodeJSInstallation (jenkins.plugins.nodejs.tools.NodeJSInstallation)17 Test (org.junit.Test)11 FreeStyleProject (hudson.model.FreeStyleProject)10 EnvVars (hudson.EnvVars)9 Launcher (hudson.Launcher)7 Node (hudson.model.Node)7 TaskListener (hudson.model.TaskListener)7 NPMConfig (jenkins.plugins.nodejs.configfiles.NPMConfig)5 IOException (java.io.IOException)4 FilePath (hudson.FilePath)3 Config (org.jenkinsci.lib.configprovider.model.Config)3 Issue (org.jvnet.hudson.test.Issue)3 AbortException (hudson.AbortException)2 File (java.io.File)2 Verifier (jenkins.plugins.nodejs.CIBuilderHelper.Verifier)2 EnvVarVerifier (jenkins.plugins.nodejs.VerifyEnvVariableBuilder.EnvVarVerifier)2 DetectionFailedException (jenkins.plugins.nodejs.tools.DetectionFailedException)2 ConfigFile (org.jenkinsci.lib.configprovider.model.ConfigFile)2 Computer (hudson.model.Computer)1 InstallSourceProperty (hudson.tools.InstallSourceProperty)1