use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class FullConfigSaveMergeFlowTest method shouldCheckinGeneratedConfigXMLToConfigRepo.
@Test
public void shouldCheckinGeneratedConfigXMLToConfigRepo() throws Exception {
String mergedConfig = "merged_config";
Date currentTime = mock(Date.class);
ArgumentCaptor<GoConfigRevision> revisionArgumentCaptor = ArgumentCaptor.forClass(GoConfigRevision.class);
when(writer.documentFrom(configForEdit)).thenReturn(document);
when(configRepository.getConfigMergedWithLatestRevision(any(GoConfigRevision.class), any(String.class))).thenReturn(mergedConfig);
when(writer.toString(document)).thenReturn("cruise_config");
when(serverVersion.version()).thenReturn("16.13.0");
when(timeProvider.currentTime()).thenReturn(currentTime);
when(loader.loadConfigHolder(any(String.class), any(MagicalGoConfigXmlLoader.Callback.class))).thenReturn(new GoConfigHolder(new BasicCruiseConfig(), new BasicCruiseConfig()));
doNothing().when(configRepository).checkin(revisionArgumentCaptor.capture());
flow.execute(updateConfigCommand, partials, "test_user");
GoConfigRevision goConfigRevision = revisionArgumentCaptor.getValue();
assertThat(goConfigRevision.getContent(), is(mergedConfig));
assertThat(goConfigRevision.getUsername(), is("test_user"));
assertThat(goConfigRevision.getMd5(), is(updateConfigCommand.configForEdit().getMd5()));
assertThat(goConfigRevision.getGoVersion(), is("16.13.0"));
}
use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class FullConfigSaveMergeFlowTest method shouldMergeConfigWithLatestRevision.
@Test
public void shouldMergeConfigWithLatestRevision() throws Exception {
when(writer.documentFrom(configForEdit)).thenReturn(document);
when(writer.toString(document)).thenReturn("cruise_config");
when(loader.loadConfigHolder(any(String.class), any(MagicalGoConfigXmlLoader.Callback.class))).thenReturn(new GoConfigHolder(new BasicCruiseConfig(), new BasicCruiseConfig()));
flow.execute(updateConfigCommand, partials, null);
verify(configRepository).getConfigMergedWithLatestRevision(new GoConfigRevision("config", "temporary-md5-for-branch", "user", "version", new TimeProvider()), "md5");
}
use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class FullConfigSaveNormalFlowTest method shouldCheckinGeneratedConfigXMLToConfigRepo.
@Test
public void shouldCheckinGeneratedConfigXMLToConfigRepo() throws Exception {
String configAsXml = "cruise config as xml";
Date currentTime = mock(Date.class);
ArgumentCaptor<GoConfigRevision> revisionArgumentCaptor = ArgumentCaptor.forClass(GoConfigRevision.class);
when(writer.documentFrom(configForEdit)).thenReturn(document);
when(writer.toString(document)).thenReturn(configAsXml);
when(loader.preprocessAndValidate(configForEdit)).thenReturn(new BasicCruiseConfig());
when(serverVersion.version()).thenReturn("16.13.0");
when(timeProvider.currentTime()).thenReturn(currentTime);
doNothing().when(configRepository).checkin(revisionArgumentCaptor.capture());
flow.execute(updateConfigCommand, partials, "test_user");
GoConfigRevision goConfigRevision = revisionArgumentCaptor.getValue();
assertThat(goConfigRevision.getContent(), is(configAsXml));
assertThat(goConfigRevision.getUsername(), is("test_user"));
assertThat(goConfigRevision.getMd5(), is(updateConfigCommand.configForEdit().getMd5()));
assertThat(goConfigRevision.getGoVersion(), is("16.13.0"));
assertThat(goConfigRevision.getTime(), is(currentTime));
}
use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class ConfigRepositoryTest method shouldFailWhenDoesNotFindARev.
@Test
public void shouldFailWhenDoesNotFindARev() throws Exception {
configRepo.checkin(new GoConfigRevision("v1", "md5-v1", "user-name", "100.3.9", new TimeProvider()));
try {
configRepo.getRevision("some-random-revision");
fail("should have failed as revision does not exist");
} catch (RuntimeException e) {
assertThat(e.getMessage(), is("There is no config version corresponding to md5: 'some-random-revision'"));
}
}
use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class ConfigRepositoryTest method shouldCommitIntoGivenBranch.
@Test
public void shouldCommitIntoGivenBranch() throws Exception {
configRepo.checkin(goConfigRevision("something", "md5-1"));
RevCommit revCommitOnMaster = configRepo.getCurrentRevCommit();
String branchName = "branch1";
configRepo.createBranch(branchName, revCommitOnMaster);
String newConfigXML = "config-xml";
GoConfigRevision configRevision = new GoConfigRevision(newConfigXML, "md5", "user", "version", new TimeProvider());
RevCommit branchRevCommit = configRepo.checkinToBranch(branchName, configRevision);
assertThat(branchRevCommit, is(notNullValue()));
assertThat(getLatestConfigAt(branchName), is(newConfigXML));
assertThat(configRepo.getCurrentRevCommit(), is(revCommitOnMaster));
}
Aggregations