use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldMatchSearchStringInDecreasingOrder.
@Test
public void shouldMatchSearchStringInDecreasingOrder() throws Exception {
ScmMaterial material = material();
repo.saveOrUpdate(material.createMaterialInstance());
MaterialRevision first = saveOneScmModification("40c95a3c41f54b5fb3107982cf2acd08783f102a", material, "pavan", "meet_you_in_hell.txt", "comment");
MaterialRevision second = saveOneScmModification("c30c471137f31a4bf735f653f888e799f6deec04", material, "turn_her", "of_course_he_will_be_there_first.txt", "comment");
List<MatchedRevision> revisions = repo.findRevisionsMatching(material.config(), "");
assertThat(revisions.size(), is(2));
assertMatchedRevision(revisions.get(0), second.getLatestShortRevision(), second.getLatestRevisionString(), "turn_her", second.getDateOfLatestModification(), "comment");
assertMatchedRevision(revisions.get(1), first.getLatestShortRevision(), first.getLatestRevisionString(), "pavan", first.getDateOfLatestModification(), "comment");
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldCacheModificationsForMaterialCorrectly.
@Test
public void shouldCacheModificationsForMaterialCorrectly() throws Exception {
final ScmMaterial material = material();
MaterialInstance materialInstance = material.createMaterialInstance();
repo.saveOrUpdate(materialInstance);
saveOneScmModification("1", material, "user1", "1.txt", "comment1");
saveOneScmModification("2", material, "user2", "2.txt", "comment2");
saveOneScmModification("3", material, "user3", "3.txt", "comment3");
saveOneScmModification("4", material, "user4", "4.txt", "comment4");
saveOneScmModification("5", material, "user5", "5.txt", "comment5");
Long totalCount = repo.getTotalModificationsFor(materialInstance);
totalCount = (Long) goCache.get(repo.materialModificationCountKey(materialInstance));
final Modification modOne = new Modification("user", "comment", "email@gmail.com", new Date(), "123");
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
MaterialInstance foo = repo.findOrCreateFrom(material);
repo.saveModifications(foo, asList(modOne));
}
});
totalCount = (Long) goCache.get(repo.materialModificationCountKey(materialInstance));
assertThat(totalCount, is(nullValue()));
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldFindLatestRevision.
@Test
public void shouldFindLatestRevision() throws Exception {
ScmMaterial material = material();
repo.saveOrUpdate(material.createMaterialInstance());
MaterialRevision first = saveOneScmModification("40c95a3c41f54b5fb3107982cf2acd08783f102a", material, "pavan", "meet_you_in_hell.txt", "comment");
MaterialRevision second = saveOneScmModification("c30c471137f31a4bf735f653f888e799f6deec04", material, "turn_her", "of_course_he_will_be_there_first.txt", "comment");
MaterialRevisions materialRevisions = repo.findLatestModification(material);
List<MaterialRevision> revisions = materialRevisions.getRevisions();
assertThat(revisions.size(), is(1));
MaterialRevision materialRevision = revisions.get(0);
assertThat(materialRevision.getLatestRevisionString(), is(second.getLatestRevisionString()));
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class PipelineLabelTest method shouldTruncateMaterialRevision.
@Test
public void shouldTruncateMaterialRevision() throws Exception {
PipelineLabel label = PipelineLabel.create("release-${svnMaterial}-${git[:6]}");
MaterialRevisions materialRevisions = ModificationsMother.oneUserOneFile();
ScmMaterial material = MaterialsMother.gitMaterial("");
material.setName(new CaseInsensitiveString("git"));
Modification modification = new Modification();
modification.setRevision("8c8a273e12a45e57fed5ce978d830eb482f6f666");
materialRevisions.addRevision(material, modification);
label.updateLabel(materialRevisions.getNamedRevisions());
assertThat(label.toString(), is("release-" + ModificationsMother.currentRevision() + "-8c8a27"));
}
use of com.thoughtworks.go.config.materials.ScmMaterial in project gocd by gocd.
the class PipelineLabelTest method shouldReplaceTheTemplateWithGitMaterialRevision.
@Test
public void shouldReplaceTheTemplateWithGitMaterialRevision() throws Exception {
PipelineLabel label = PipelineLabel.create("release-${svnMaterial}-${git}");
MaterialRevisions materialRevisions = ModificationsMother.oneUserOneFile();
ScmMaterial material = MaterialsMother.gitMaterial("");
material.setName(new CaseInsensitiveString("git"));
Modification modification = new Modification();
modification.setRevision("8c8a273e12a45e57fed5ce978d830eb482f6f666");
materialRevisions.addRevision(material, modification);
label.updateLabel(materialRevisions.getNamedRevisions());
assertThat(label.toString(), is("release-" + ModificationsMother.currentRevision() + "-8c8a273e12a45e57fed5ce978d830eb482f6f666"));
}
Aggregations