Search in sources :

Example 16 with GoConfigRevision

use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.

the class ConfigRepositoryTest method shouldShowDiffForAnyTwoConfigMd5s.

@Test
public void shouldShowDiffForAnyTwoConfigMd5s() throws Exception {
    configRepo.checkin(goConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 33), "md5-1"));
    configRepo.checkin(new GoConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 60), "md5-2", "user-2", "13.2", new TimeProvider()));
    configRepo.checkin(new GoConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 55), "md5-3", "user-2", "13.2", new TimeProvider()));
    String configChangesLine1 = "-<cruise schemaVersion='33'>";
    String configChangesLine2 = "+<cruise schemaVersion='60'>";
    String configChangesLine3 = "+<cruise schemaVersion='55'>";
    String actual = configRepo.configChangesFor("md5-2", "md5-1");
    assertThat(actual, containsString(configChangesLine1));
    assertThat(actual, containsString(configChangesLine2));
    actual = configRepo.configChangesFor("md5-3", "md5-1");
    assertThat(actual, containsString(configChangesLine1));
    assertThat(actual, containsString(configChangesLine3));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) GoConfigRevision(com.thoughtworks.go.domain.GoConfigRevision) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 17 with GoConfigRevision

use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.

the class ConfigRepositoryTest method shouldShowDiffBetweenAnyTwoGitRevisionsGivenTheirMd5s.

@Test
public void shouldShowDiffBetweenAnyTwoGitRevisionsGivenTheirMd5s() throws Exception {
    configRepo.checkin(goConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 33), "md5-1"));
    configRepo.checkin(new GoConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 60), "md5-2", "user-2", "13.2", new TimeProvider()));
    configRepo.checkin(new GoConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 55), "md5-3", "user-1", "13.2", new TimeProvider()));
    String configChangesLine1 = "-<cruise schemaVersion='33'>";
    String configChangesLine2 = "+<cruise schemaVersion='55'>";
    String actual = configRepo.findDiffBetweenTwoRevisions(configRepo.getRevCommitForMd5("md5-3"), configRepo.getRevCommitForMd5("md5-1"));
    assertThat(actual, containsString(configChangesLine1));
    assertThat(actual, containsString(configChangesLine2));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) GoConfigRevision(com.thoughtworks.go.domain.GoConfigRevision) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 18 with GoConfigRevision

use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.

the class ConfigRepositoryTest method shouldShowDiffForAnyTwoCommitSHAs.

@Test
public void shouldShowDiffForAnyTwoCommitSHAs() throws Exception {
    configRepo.checkin(goConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 33), "md5-1"));
    configRepo.checkin(new GoConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 60), "md5-2", "user-2", "13.2", new TimeProvider()));
    configRepo.checkin(new GoConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 55), "md5-3", "user-2", "13.2", new TimeProvider()));
    GoConfigRevisions commits = configRepo.getCommits(10, 0);
    String firstCommitSHA = commits.get(2).getCommitSHA();
    String secondCommitSHA = commits.get(1).getCommitSHA();
    String thirdCommitSHA = commits.get(0).getCommitSHA();
    String configChangesLine1 = "-<cruise schemaVersion='33'>";
    String configChangesLine2 = "+<cruise schemaVersion='60'>";
    String configChangesLine3 = "+<cruise schemaVersion='55'>";
    String actual = configRepo.configChangesForCommits(secondCommitSHA, firstCommitSHA);
    assertThat(actual, containsString(configChangesLine1));
    assertThat(actual, containsString(configChangesLine2));
    actual = configRepo.configChangesForCommits(thirdCommitSHA, firstCommitSHA);
    assertThat(actual, containsString(configChangesLine1));
    assertThat(actual, containsString(configChangesLine3));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) GoConfigRevision(com.thoughtworks.go.domain.GoConfigRevision) GoConfigRevisions(com.thoughtworks.go.GoConfigRevisions) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 19 with GoConfigRevision

use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.

the class ConfigRepositoryTest method shouldShowDiffBetweenTwoConsecutiveGitRevisions.

@Test
public void shouldShowDiffBetweenTwoConsecutiveGitRevisions() throws Exception {
    configRepo.checkin(goConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 33), "md5-1"));
    RevCommit previousCommit = configRepo.revisions().iterator().next();
    configRepo.checkin(new GoConfigRevision(ConfigFileFixture.configWithPipeline(ConfigFileFixture.SIMPLE_PIPELINE, 60), "md5-2", "user-2", "13.2", new TimeProvider()));
    RevCommit latestCommit = configRepo.revisions().iterator().next();
    String configChangesLine1 = "-<cruise schemaVersion='33'>";
    String configChangesLine2 = "+<cruise schemaVersion='60'>";
    String actual = configRepo.findDiffBetweenTwoRevisions(latestCommit, previousCommit);
    assertThat(actual, containsString(configChangesLine1));
    assertThat(actual, containsString(configChangesLine2));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) GoConfigRevision(com.thoughtworks.go.domain.GoConfigRevision) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 20 with GoConfigRevision

use of com.thoughtworks.go.domain.GoConfigRevision in project gocd by gocd.

the class ConfigRepositoryTest method shouldUnderstandRevision_current_asLatestRevision.

@Test
public void shouldUnderstandRevision_current_asLatestRevision() 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("current").getMd5(), is("md5-v2"));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) GoConfigRevision(com.thoughtworks.go.domain.GoConfigRevision) Test(org.junit.Test)

Aggregations

GoConfigRevision (com.thoughtworks.go.domain.GoConfigRevision)28 Test (org.junit.Test)22 TimeProvider (com.thoughtworks.go.util.TimeProvider)13 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 StringContains.containsString (org.hamcrest.core.StringContains.containsString)3 GoConfigRevisions (com.thoughtworks.go.GoConfigRevisions)2 File (java.io.File)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Date (java.util.Date)2 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)1 FileOutputStream (java.io.FileOutputStream)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 DateTime (org.joda.time.DateTime)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 SecurityContext (org.springframework.security.context.SecurityContext)1