use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class ConfigRepositoryTest method shouldBeAbleToCheckin.
@Test
public void shouldBeAbleToCheckin() throws Exception {
configRepo.checkin(new GoConfigRevision("v1", "md5-v1", "user-name", "100.3.9", new TimeProvider()));
configRepo.checkin(new GoConfigRevision("v1 v2", "md5-v2", "user-name", "100.9.8", new TimeProvider()));
assertThat(configRepo.getRevision("md5-v1").getContent(), is("v1"));
assertThat(configRepo.getRevision("md5-v2").getContent(), is("v1 v2"));
}
use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class ConfigRepositoryTest method shouldRemoveUnwantedDataFromDiff.
@Test
public void shouldRemoveUnwantedDataFromDiff() throws Exception {
configRepo.checkin(goConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 33), "md5-1"));
String configXml = ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 60);
configRepo.checkin(new GoConfigRevision(configXml, "md5-2", "user-2", "13.2", new TimeProvider()));
String configChangesLine1 = "-<cruise schemaVersion='33'>";
String configChangesLine2 = "+<cruise schemaVersion='60'>";
String actual = configRepo.configChangesFor("md5-2", "md5-1");
assertThat(actual, containsString(configChangesLine1));
assertThat(actual, containsString(configChangesLine2));
assertThat(actual, not(containsString("--- a/cruise-config.xml")));
assertThat(actual, not(containsString("+++ b/cruise-config.xml")));
}
use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class ConfigRepositoryTest method shouldGetCommitsCorrectly.
@Test
public void shouldGetCommitsCorrectly() throws Exception {
configRepo.checkin(new GoConfigRevision("v1", "md5-v1", "user-name", "100.3.9", new TimeProvider()));
configRepo.checkin(new GoConfigRevision("v2", "md5-v2", "user-name", "100.3.9", new TimeProvider()));
configRepo.checkin(new GoConfigRevision("v3", "md5-v3", "user-name", "100.3.9", new TimeProvider()));
configRepo.checkin(new GoConfigRevision("v4", "md5-v4", "user-name", "100.3.9", new TimeProvider()));
GoConfigRevisions goConfigRevisions = configRepo.getCommits(3, 0);
assertThat(goConfigRevisions.size(), is(3));
assertThat(goConfigRevisions.get(0).getContent(), is(nullValue()));
assertThat(goConfigRevisions.get(0).getMd5(), is("md5-v4"));
assertThat(goConfigRevisions.get(1).getMd5(), is("md5-v3"));
assertThat(goConfigRevisions.get(2).getMd5(), is("md5-v2"));
goConfigRevisions = configRepo.getCommits(3, 3);
assertThat(goConfigRevisions.size(), is(1));
assertThat(goConfigRevisions.get(0).getMd5(), is("md5-v1"));
}
use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class ConfigRepositoryTest method shouldNotCommitWhenNothingChanged.
@Test
public void shouldNotCommitWhenNothingChanged() throws Exception {
configRepo.checkin(new GoConfigRevision("v1", "md5-v1", "user-name", "100.3.9", new TimeProvider()));
// md5 is solely trusted
configRepo.checkin(new GoConfigRevision("v1 v2", "md5-v1", "loser-name", "501.9.8", new TimeProvider()));
Iterator<RevCommit> commitIterator = configRepo.revisions().iterator();
int size = 0;
while (commitIterator.hasNext()) {
size++;
commitIterator.next();
}
assertThat(size, is(1));
}
use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldUse_UserFromSession_asConfigModifyingUserWhenNoneGiven.
@Test
public void shouldUse_UserFromSession_asConfigModifyingUserWhenNoneGiven() throws GitAPIException, IOException {
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(new UsernamePasswordAuthenticationToken(new User("loser_boozer", "pass", true, true, true, true, new GrantedAuthority[] {}), null));
goConfigDao.updateMailHost(getMailHost("mailhost.local"));
CruiseConfig cruiseConfig = goConfigDao.load();
GoConfigRevision revision = configRepository.getRevision(cruiseConfig.getMd5());
assertThat(revision.getUsername(), is("loser_boozer"));
}
Aggregations