Search in sources :

Example 1 with GoConfigRevisions

use of com.thoughtworks.go.GoConfigRevisions 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"));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) GoConfigRevision(com.thoughtworks.go.domain.GoConfigRevision) GoConfigRevisions(com.thoughtworks.go.GoConfigRevisions) Test(org.junit.Test)

Example 2 with GoConfigRevisions

use of com.thoughtworks.go.GoConfigRevisions 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)

Aggregations

GoConfigRevisions (com.thoughtworks.go.GoConfigRevisions)2 GoConfigRevision (com.thoughtworks.go.domain.GoConfigRevision)2 TimeProvider (com.thoughtworks.go.util.TimeProvider)2 Test (org.junit.Test)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1