use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class PackageMaterialTest method shouldPopulateEnvironmentContext.
@Test
public void shouldPopulateEnvironmentContext() {
PackageMaterial material = new PackageMaterial();
PackageRepository repository = PackageRepositoryMother.create("repo-id", "tw-dev", "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "v1"), ConfigurationPropertyMother.create("repo-secure", true, "value")));
material.setPackageDefinition(PackageDefinitionMother.create("p-id", "go-agent", new Configuration(ConfigurationPropertyMother.create("k2", false, "v2"), ConfigurationPropertyMother.create("pkg-secure", true, "value")), repository));
material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
Modifications modifications = new Modifications(new Modification(null, null, null, new Date(), "revision-123"));
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
assertThat(environmentVariableContext.getProperty("GO_REPO_TW_DEV_GO_AGENT_K1"), is("v1"));
assertThat(environmentVariableContext.getProperty("GO_REPO_TW_DEV_GO_AGENT_REPO_SECURE"), is("value"));
assertThat(environmentVariableContext.getPropertyForDisplay("GO_REPO_TW_DEV_GO_AGENT_REPO_SECURE"), is(EnvironmentVariableContext.EnvironmentVariable.MASK_VALUE));
assertThat(environmentVariableContext.getProperty("GO_PACKAGE_TW_DEV_GO_AGENT_K2"), is("v2"));
assertThat(environmentVariableContext.getProperty("GO_PACKAGE_TW_DEV_GO_AGENT_PKG_SECURE"), is("value"));
assertThat(environmentVariableContext.getPropertyForDisplay("GO_PACKAGE_TW_DEV_GO_AGENT_PKG_SECURE"), is(EnvironmentVariableContext.EnvironmentVariable.MASK_VALUE));
assertThat(environmentVariableContext.getProperty("GO_PACKAGE_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class DependencyMaterialTest method shouldParseMaterialRevisionWithPipelineLabel.
@Test
public void shouldParseMaterialRevisionWithPipelineLabel() {
ArrayList<Modification> mods = new ArrayList<>();
Modification mod = new Modification(new Date(), "pipelineName/123/stageName/2", "pipeline-label-123", null);
mods.add(mod);
DependencyMaterialRevision revision = (DependencyMaterialRevision) new Modifications(mods).latestRevision(dependencyMaterial);
assertThat(revision.getRevision(), is("pipelineName/123/stageName/2"));
assertThat(revision.getPipelineLabel(), is("pipeline-label-123"));
assertThat(revision.getPipelineCounter(), is(123));
assertThat(revision.getPipelineName(), is("pipelineName"));
assertThat(revision.getStageName(), is("stageName"));
assertThat(revision.getStageCounter(), is(2));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class GitMaterialShallowCloneTest method updateToANewRevisionShouldNotResultInUnshallowing.
@Test
public void updateToANewRevisionShouldNotResultInUnshallowing() throws IOException {
GitMaterial material = new GitMaterial(repo.projectRepositoryUrl(), true);
material.updateTo(inMemoryConsumer(), workingDir, new RevisionContext(REVISION_4, REVISION_4, 1), context());
assertThat(localRepoFor(material).isShallow(), is(true));
List<Modification> modifications = repo.addFileAndPush("newfile", "add new file");
StringRevision newRevision = new StringRevision(modifications.get(0).getRevision());
material.updateTo(inMemoryConsumer(), workingDir, new RevisionContext(newRevision, newRevision, 1), context());
assertThat(new File(workingDir, "newfile").exists(), is(true));
assertThat(localRepoFor(material).isShallow(), is(true));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class P4OutputParserTest method shouldRetrieveModificationFromDescription.
@Test
public void shouldRetrieveModificationFromDescription() throws Exception {
String output = "Change 2 by cce123user@connect4_10.18.2.31 on 2008/08/19 15:04:43\n" + "\n" + "\tAdded config file\n" + "\n" + "Affected files ...\n" + "\n" + "... //depot/cruise-config.xml#1 add\n" + "... //depot/README.txt#2 edit\n" + "... //depot/cruise-output/log.xml#1 delete\n" + "";
Modification mod = parser.modificationFromDescription(output, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
assertThat(mod.getRevision(), is("2"));
assertThat(mod.getUserName(), is("cce123user@connect4_10.18.2.31"));
assertThat(mod.getModifiedTime(), is(DESCRIPTION_FORMAT.parse("2008/08/19 15:04:43")));
assertThat(mod.getComment(), is("Added config file"));
List<ModifiedFile> files = mod.getModifiedFiles();
assertThat(files.size(), is(3));
assertThat(files.get(0).getAction(), is(ModifiedAction.added));
assertThat(files.get(0).getFileName(), is("cruise-config.xml"));
assertThat(files.get(1).getAction(), is(ModifiedAction.modified));
assertThat(files.get(2).getAction(), is(ModifiedAction.deleted));
assertThat(files.get(2).getFileName(), is("cruise-output/log.xml"));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class P4OutputParserTest method shouldParseCorrectlyWhenCommentIsEmpty.
@Test
public void shouldParseCorrectlyWhenCommentIsEmpty() throws P4OutputParseException {
String description = "Change 102 by godev@blrstdcrspair03 on 2013/06/04 12:00:35\n" + "\n" + "\n" + "Affected files ...\n" + "\n" + "... //another_depot/1.txt#6 edit";
Modification modification = parser.modificationFromDescription(description, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
assertThat(modification.getComment(), is(""));
}
Aggregations