use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class GoPartialConfigTest method shouldRemovePartialWhenNoLongerInWatchList.
@Test
public void shouldRemovePartialWhenNoLongerInWatchList() throws Exception {
ScmMaterialConfig material = setOneConfigRepo();
PartialConfig part = new PartialConfig();
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(part);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
assertThat(partialConfig.lastPartials().size(), is(1));
assertThat(partialConfig.lastPartials().get(0), is(part));
// we change current configuration
ScmMaterialConfig othermaterial = new GitMaterialConfig("http://myother.git");
cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(othermaterial, "myplugin")));
configWatchList.onConfigChange(cruiseConfig);
assertThat(partialConfig.lastPartials().size(), is(0));
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class GoPartialConfigTest method shouldNotifyListenersAfterUpdatingMapOfLatestValidConfig.
@Test
public void shouldNotifyListenersAfterUpdatingMapOfLatestValidConfig() {
ScmMaterialConfig material = setOneConfigRepo();
PartialConfig part = new PartialConfig();
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(part);
PartialConfigUpdateCompletedListener listener = mock(PartialConfigUpdateCompletedListener.class);
repoConfigDataSource.registerListener(listener);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
verify(listener, times(1)).onSuccessPartialConfig(any(ConfigRepoConfig.class), any(PartialConfig.class));
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldSetConfigOriginInCruiseConfig_AfterLoadingConfigFile.
@Test
public void shouldSetConfigOriginInCruiseConfig_AfterLoadingConfigFile() throws Exception {
GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(ConfigFileFixture.CONFIG, new MagicalGoConfigXmlLoader.Callback() {
@Override
public void call(CruiseConfig cruiseConfig) {
cruiseConfig.setPartials(asList(new PartialConfig()));
}
});
assertThat(goConfigHolder.config.getOrigin(), Is.<ConfigOrigin>is(new MergeConfigOrigin()));
assertThat(goConfigHolder.configForEdit.getOrigin(), Is.<ConfigOrigin>is(new FileConfigOrigin()));
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldLoadPartialConfigWithEnvironment.
@Test
public void shouldLoadPartialConfigWithEnvironment() throws Exception {
String partialConfigWithPipeline = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'>\n" + "<environments>" + " <environment name='uat'>" + " <agents>" + " <physical uuid='1'/>" + " <physical uuid='2'/>" + " </agents>" + " </environment>" + " <environment name='prod'>" + " <agents>" + " <physical uuid='2'/>" + " </agents>" + " </environment>" + "</environments>" + "</cruise>\n";
PartialConfig partialConfig = xmlLoader.fromXmlPartial(toInputStream(partialConfigWithPipeline), PartialConfig.class);
EnvironmentsConfig environmentsConfig = partialConfig.getEnvironments();
assertThat(environmentsConfig.size(), is(2));
EnvironmentPipelineMatchers matchers = environmentsConfig.matchers();
assertThat(matchers.size(), is(2));
ArrayList<String> uat_uuids = new ArrayList<String>() {
{
add("1");
add("2");
}
};
ArrayList<String> prod_uuids = new ArrayList<String>() {
{
add("2");
}
};
assertThat(matchers, hasItem(new EnvironmentPipelineMatcher(new CaseInsensitiveString("uat"), uat_uuids, new EnvironmentPipelinesConfig())));
assertThat(matchers, hasItem(new EnvironmentPipelineMatcher(new CaseInsensitiveString("prod"), prod_uuids, new EnvironmentPipelinesConfig())));
}
use of com.thoughtworks.go.config.remote.PartialConfig in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldLoadPartialConfigWithPipeline.
@Test
public void shouldLoadPartialConfigWithPipeline() throws Exception {
String partialConfigWithPipeline = "<cruise schemaVersion='" + CONFIG_SCHEMA_VERSION + "'>\n" + "<pipelines group=\"first\">\n" + "<pipeline name=\"pipeline\">\n" + " <materials>\n" + " <hg url=\"/hgrepo\"/>\n" + " </materials>\n" + " <stage name=\"mingle\">\n" + " <jobs>\n" + " <job name=\"functional\">\n" + " <artifacts>\n" + " <log src=\"artifact1.xml\" dest=\"cruise-output\" />\n" + " </artifacts>\n" + " </job>\n" + " </jobs>\n" + " </stage>\n" + "</pipeline>\n" + "</pipelines>\n" + "</cruise>\n";
PartialConfig partialConfig = xmlLoader.fromXmlPartial(toInputStream(partialConfigWithPipeline), PartialConfig.class);
assertThat(partialConfig.getGroups().size(), is(1));
PipelineConfig pipeline = partialConfig.getGroups().get(0).getPipelines().get(0);
assertThat(pipeline.name(), is(new CaseInsensitiveString("pipeline")));
assertThat(pipeline.size(), is(1));
assertThat(pipeline.findBy(new CaseInsensitiveString("mingle")).jobConfigByInstanceName("functional", true), is(notNullValue()));
}
Aggregations