Search in sources :

Example 1 with Verifier

use of jenkins.plugins.nodejs.CIBuilderHelper.Verifier in project nodejs-plugin by jenkinsci.

the class NodeJSCommandInterpreterTest method test_creation_of_config.

@Test
public void test_creation_of_config() throws Exception {
    Config config = createSetting("my-config-id", "email=foo@acme.com", null);
    NodeJSInstallation installation = mockInstaller();
    NodeJSCommandInterpreter builder = CIBuilderHelper.createMock("test_creation_of_config", installation, config.id, new Verifier() {

        @Override
        public void verify(AbstractBuild<?, ?> build, Launcher launcher, TaskListener listener) throws Exception {
            EnvVars env = build.getEnvironment(listener);
            String var = NodeJSConstants.NPM_USERCONFIG;
            String value = env.get(var);
            assertTrue("variable " + var + " not set", env.containsKey(var));
            assertNotNull("empty value for environment variable " + var, value);
            assertTrue("file of variable " + var + " does not exists or is not a file", new File(value).isFile());
        }
    });
    FreeStyleProject job = j.createFreeStyleProject();
    job.getBuildersList().add(builder);
    j.assertBuildStatusSuccess(job.scheduleBuild2(0));
}
Also used : Config(org.jenkinsci.lib.configprovider.model.Config) NPMConfig(jenkins.plugins.nodejs.configfiles.NPMConfig) Verifier(jenkins.plugins.nodejs.CIBuilderHelper.Verifier) FreeStyleProject(hudson.model.FreeStyleProject) IOException(java.io.IOException) DetectionFailedException(jenkins.plugins.nodejs.tools.DetectionFailedException) NodeJSInstallation(jenkins.plugins.nodejs.tools.NodeJSInstallation) EnvVars(hudson.EnvVars) TaskListener(hudson.model.TaskListener) Launcher(hudson.Launcher) File(java.io.File) Test(org.junit.Test)

Aggregations

EnvVars (hudson.EnvVars)1 Launcher (hudson.Launcher)1 FreeStyleProject (hudson.model.FreeStyleProject)1 TaskListener (hudson.model.TaskListener)1 File (java.io.File)1 IOException (java.io.IOException)1 Verifier (jenkins.plugins.nodejs.CIBuilderHelper.Verifier)1 NPMConfig (jenkins.plugins.nodejs.configfiles.NPMConfig)1 DetectionFailedException (jenkins.plugins.nodejs.tools.DetectionFailedException)1 NodeJSInstallation (jenkins.plugins.nodejs.tools.NodeJSInstallation)1 Config (org.jenkinsci.lib.configprovider.model.Config)1 Test (org.junit.Test)1