use of jenkins.plugins.nodejs.configfiles.Npmrc in project nodejs-plugin by jenkinsci.
the class NpmrcFileSupplyTest method test_supply_npmrc_with_registry.
@Test
public void test_supply_npmrc_with_registry() throws Exception {
StandardUsernameCredentials user = createUser("test-user-id", "myuser", "mypassword");
NPMRegistry privateRegistry = new NPMRegistry("https://private.organization.com/", user.getId(), null);
NPMRegistry officalRegistry = new NPMRegistry("https://registry.npmjs.org/", null, "@user1 user2");
Config config = createSetting("mytest", "email=guest@example.com", Arrays.asList(privateRegistry, officalRegistry));
FreeStyleBuild build = new MockBuild(j.createFreeStyleProject(), folder.newFolder());
FilePath npmrcFile = ConfigFileManager.provisionConfigFile(new ConfigFile(config.id, null, true), null, build, build.getWorkspace(), j.createTaskListener(), new ArrayList<String>(1));
assertTrue(npmrcFile.exists());
assertTrue(npmrcFile.length() > 0);
Npmrc npmrc = Npmrc.load(new File(npmrcFile.getRemote()));
assertTrue("Missing setting email", npmrc.contains("email"));
assertEquals("Unexpected value from settings email", "guest@example.com", npmrc.get("email"));
}
Aggregations