use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project nodejs-plugin by jenkinsci.
the class NodeJSCommandInterpreterTest method test_inject_path_variable.
@Issue("JENKINS-41947")
@Test
public void test_inject_path_variable() throws Exception {
NodeJSInstallation installation = mockInstaller();
NodeJSCommandInterpreter builder = CIBuilderHelper.createMock("test_executable_value", installation, null, new CIBuilderHelper.Verifier() {
@Override
public void verify(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws Exception {
assertFalse("No Environments", build.getEnvironments().isEmpty());
EnvVars env = build.getEnvironment(listener);
Assertions.assertThat(env.keySet()).contains(NodeJSConstants.ENVVAR_NODEJS_PATH, NodeJSConstants.ENVVAR_NODEJS_HOME);
assertEquals(getTestHome(), env.get(NodeJSConstants.ENVVAR_NODEJS_HOME));
assertEquals(getTestHome(), env.get(NodeJSConstants.ENVVAR_NODE_HOME));
assertEquals(getTestBin(), env.get(NodeJSConstants.ENVVAR_NODEJS_PATH));
}
});
FreeStyleProject job = j.createFreeStyleProject();
job.getBuildersList().add(builder);
j.assertBuildStatusSuccess(job.scheduleBuild2(0));
}
use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project nodejs-plugin by jenkinsci.
the class NodeJSCommandInterpreterTest method mockInstaller.
private NodeJSInstallation mockInstaller() throws IOException, InterruptedException {
NodeJSInstallation mock = mock(NodeJSInstallation.class);
when(mock.forNode(any(Node.class), any(TaskListener.class))).then(RETURNS_SELF);
when(mock.forEnvironment(any(EnvVars.class))).then(RETURNS_SELF);
when(mock.getName()).thenReturn("mockNode");
when(mock.getHome()).thenReturn(getTestHome());
when(mock.getExecutable(any(Launcher.class))).thenReturn(getTestExecutable());
doCallRealMethod().when(mock).buildEnvVars(any(EnvVars.class));
return mock;
}
use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project nodejs-plugin by jenkinsci.
the class NodeJSBuildWrapperTest method test_inject_path_variable.
@Test
public void test_inject_path_variable() throws Exception {
FreeStyleProject job = j.createFreeStyleProject("free");
final Config config = createSetting("my-config-id", "", null);
NodeJSInstallation installation = spy(new NodeJSInstallation("test", getTestHome(), null));
doReturn(getTestExecutable()).when(installation).getExecutable(any(Launcher.class));
doReturn(installation).when(installation).forNode(any(Node.class), any(TaskListener.class));
doReturn(installation).when(installation).forEnvironment(any(EnvVars.class));
NodeJSBuildWrapper spy = mockWrapper(installation, config);
job.getBuildWrappersList().add(spy);
job.getBuildersList().add(new PathVerifier(installation));
j.assertBuildStatusSuccess(job.scheduleBuild2(0));
}
use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project nodejs-plugin by jenkinsci.
the class NodeJSBuildWrapperTest method test_creation_of_config.
@Test
public void test_creation_of_config() throws Exception {
FreeStyleProject job = j.createFreeStyleProject("free");
final Config config = createSetting("my-config-id", "email=foo@acme.com", null);
NodeJSInstallation installation = mockInstaller();
NodeJSBuildWrapper bw = mockWrapper(installation, config);
job.getBuildWrappersList().add(bw);
job.getBuildersList().add(new FileVerifier());
j.assertBuildStatusSuccess(job.scheduleBuild2(0));
}
use of jenkins.plugins.nodejs.tools.NodeJSInstallation in project nodejs-plugin by jenkinsci.
the class NodeJSBuildWrapperTest method mockInstaller.
private NodeJSInstallation mockInstaller() throws Exception {
NodeJSInstallation mock = mock(NodeJSInstallation.class);
when(mock.forNode(any(Node.class), any(TaskListener.class))).then(RETURNS_SELF);
when(mock.forEnvironment(any(EnvVars.class))).then(RETURNS_SELF);
when(mock.getName()).thenReturn("mockNode");
when(mock.getHome()).thenReturn(getTestHome());
when(mock.getExecutable(any(Launcher.class))).thenReturn(getTestExecutable());
return mock;
}
Aggregations