@Test public void shouldFailToAddDuplicatePipelineAlreadyDefinedInConfigRepo() { pipelines = new BasicPipelineConfigs( "group_main", new Authorization(), PipelineConfigMother.pipelineConfig("pipe1")); BasicCruiseConfig localCruiseConfig = new BasicCruiseConfig(pipelines); cruiseConfig = new BasicCruiseConfig( localCruiseConfig, PartialConfigMother.withPipelineInGroup("pipe2", "remote_group")); PipelineConfig pipe2Dup = PipelineConfigMother.pipelineConfig("pipe2"); try { cruiseConfig.addPipeline("doesNotMatterWhichGroup", pipe2Dup); } catch (Exception ex) { assertThat( ex.getMessage(), is( "Pipeline called 'pipe2' is already defined in configuration repository http://some.git at 1234fed")); } assertThat(cruiseConfig.allPipelines().size(), is(2)); assertThat(cruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipe2")), is(true)); assertThat(localCruiseConfig.allPipelines().size(), is(1)); assertThat(localCruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipe1")), is(true)); assertThat(localCruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipe2")), is(false)); }
@Test public void addPipeline_shouldAddPipelineToMain() { pipelines = new BasicPipelineConfigs( "group_main", new Authorization(), PipelineConfigMother.pipelineConfig("pipe1")); pipelines.setOrigin(new FileConfigOrigin()); BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig(pipelines); cruiseConfig = new BasicCruiseConfig(mainCruiseConfig, PartialConfigMother.withPipeline("pipe2")); cruiseConfig.addPipeline("group_main", PipelineConfigMother.pipelineConfig("pipe3")); assertThat(mainCruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipe3")), is(true)); assertThat(cruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipe3")), is(true)); }
@Test public void shouldAddPipelineToExistingGroup_InMergeAndLocalScope() { pipelines = new BasicPipelineConfigs( "group_main", new Authorization(), PipelineConfigMother.pipelineConfig("pipe1")); BasicCruiseConfig localCruiseConfig = new BasicCruiseConfig(pipelines); cruiseConfig = new BasicCruiseConfig( localCruiseConfig, PartialConfigMother.withPipelineInGroup("pipe2", "remote_group")); PipelineConfig pipe3 = PipelineConfigMother.pipelineConfig("pipe3"); cruiseConfig.addPipeline("remote_group", pipe3); assertThat(cruiseConfig.allPipelines().size(), is(3)); assertThat(cruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipe3")), is(true)); assertThat(localCruiseConfig.allPipelines().size(), is(2)); assertThat(localCruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipe1")), is(true)); assertThat(localCruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipe3")), is(true)); assertThat(localCruiseConfig.pipelines("remote_group").contains(pipe3), is(true)); }