use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class MaterialAgentFactoryTest method shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace.
@Test
public void shouldCreateMaterialAgent_withAgentsUuidAsSubprocessExecutionContextNamespace() throws IOException {
String agentUuid = "uuid-01783738";
File workingDirectory = temporaryFolder.newFolder();
MaterialAgentFactory factory = new MaterialAgentFactory(new ProcessOutputStreamConsumer(new DevNull(), new DevNull()), workingDirectory, new AgentIdentifier("host", "1.1.1.1", agentUuid), packageRepositoryExtension, scmExtension);
GitMaterial gitMaterial = new GitMaterial("http://foo", "master", "dest_folder");
MaterialAgent agent = factory.createAgent(new MaterialRevision(gitMaterial));
assertThat(agent, is(instanceOf(AbstractMaterialAgent.class)));
SubprocessExecutionContext execCtx = (SubprocessExecutionContext) ReflectionUtil.getField(agent, "execCtx");
assertThat(execCtx.getProcessNamespace("fingerprint"), is(CachedDigestUtils.sha256Hex(String.format("%s%s%s", "fingerprint", agentUuid, gitMaterial.workingdir(workingDirectory)))));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class MaterialAgentFactoryTest method shouldGetPackageMaterialAgent.
@Test
public void shouldGetPackageMaterialAgent() {
File workingDirectory = new File("/tmp/workingDirectory");
MaterialRevision revision = new MaterialRevision(new PackageMaterial(), new Modifications());
MaterialAgentFactory factory = new MaterialAgentFactory(null, workingDirectory, null, packageRepositoryExtension, scmExtension);
MaterialAgent agent = factory.createAgent(revision);
assertThat(agent instanceof PackageMaterialAgent, is(true));
assertThat(ReflectionUtil.getField(agent, "packageRepositoryExtension"), is(packageRepositoryExtension));
assertThat(ReflectionUtil.getField(agent, "revision"), is(revision));
assertThat(ReflectionUtil.getField(agent, "workingDirectory"), is(workingDirectory));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class HgMultipleMaterialsTest method shouldCloneMaterialToItsDestFolder.
@Test
public void shouldCloneMaterialToItsDestFolder() throws Exception {
HgMaterial material1 = repo.createMaterial("dest1");
MaterialRevision materialRevision = new MaterialRevision(material1, material1.latestModification(pipelineDir, new TestSubprocessExecutionContext()));
materialRevision.updateTo(pipelineDir, ProcessOutputStreamConsumer.inMemoryConsumer(), new TestSubprocessExecutionContext());
assertThat(new File(pipelineDir, "dest1").exists(), is(true));
assertThat(new File(pipelineDir, "dest1/.hg").exists(), is(true));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class P4MultipleMaterialsTest method shouldUpdateToItsDestFolder.
@Test
public void shouldUpdateToItsDestFolder() {
P4Material p4Material = p4Fixture.material(VIEW_SRC, "dest1");
MaterialRevision revision = new MaterialRevision(p4Material, p4Material.latestModification(clientFolder, new TestSubprocessExecutionContext()));
revision.updateTo(clientFolder, inMemoryConsumer(), new TestSubprocessExecutionContext());
assertThat(new File(clientFolder, "dest1/net").exists(), is(true));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class PluggableSCMMaterialTest method shouldPopulateEnvironmentContextWithEnvironmentVariablesCreatedOutOfAdditionalDataFromModification.
@Test
public void shouldPopulateEnvironmentContextWithEnvironmentVariablesCreatedOutOfAdditionalDataFromModification() {
ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
SCM scmConfig = SCMMother.create("scm-id", "tw-dev", "pluginid", "version", new Configuration(k1));
PluggableSCMMaterial material = new PluggableSCMMaterial();
material.setSCMConfig(scmConfig);
material.setName(new CaseInsensitiveString("tw-dev:go-agent"));
HashMap<String, String> map = new HashMap<>();
map.put("MY_NEW_KEY", "my_value");
Modification modification = new Modification("loser", "comment", "email", new Date(), "revision-123", JsonHelper.toJsonString(map));
Modifications modifications = new Modifications(modification);
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
material.populateEnvironmentContext(environmentVariableContext, new MaterialRevision(material, modifications), null);
assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_LABEL"), is("revision-123"));
assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_K1"), is("v1"));
assertThat(environmentVariableContext.getProperty("GO_SCM_TW_DEV_GO_AGENT_MY_NEW_KEY"), is("my_value"));
}
Aggregations