use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class ScmMaterialTest method shouldEscapeHyphenFromFolderNameWhenUsedInEnvVariable.
@Test
public void shouldEscapeHyphenFromFolderNameWhenUsedInEnvVariable() {
EnvironmentVariableContext context = new EnvironmentVariableContext();
material.setFolder("folder-name");
material.setVariableWithName(context, "value", "GO_PROPERTY");
assertThat(context.getProperty("GO_PROPERTY_FOLDER_NAME"), is("value"));
assertThat(context.getProperty("GO_PROPERTY"), is(nullValue()));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class ScmMaterialTest method populateEnvironmentContextShouldSetFromAndToRevisionEnvironmentVariables.
@Test
public void populateEnvironmentContextShouldSetFromAndToRevisionEnvironmentVariables() {
EnvironmentVariableContext ctx = new EnvironmentVariableContext();
final ArrayList<Modification> modifications = new ArrayList<>();
modifications.add(new Modification("user2", "comment2", "email2", new Date(), "24"));
modifications.add(new Modification("user1", "comment1", "email1", new Date(), "23"));
MaterialRevision materialRevision = new MaterialRevision(material, modifications);
assertThat(ctx.getProperty(ScmMaterial.GO_FROM_REVISION), is(nullValue()));
assertThat(ctx.getProperty(ScmMaterial.GO_TO_REVISION), is(nullValue()));
assertThat(ctx.getProperty(ScmMaterial.GO_REVISION), is(nullValue()));
material.populateEnvironmentContext(ctx, materialRevision, new File("."));
assertThat(ctx.getProperty(ScmMaterial.GO_FROM_REVISION), is("23"));
assertThat(ctx.getProperty(ScmMaterial.GO_TO_REVISION), is("24"));
assertThat(ctx.getProperty(ScmMaterial.GO_REVISION), is("24"));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class ScmMaterialTest method shouldEscapeHyphenFromMaterialNameWhenUsedInEnvVariable.
@Test
public void shouldEscapeHyphenFromMaterialNameWhenUsedInEnvVariable() {
EnvironmentVariableContext context = new EnvironmentVariableContext();
material.setName(new CaseInsensitiveString("material-name"));
material.setVariableWithName(context, "value", "GO_PROPERTY");
assertThat(context.getProperty("GO_PROPERTY_MATERIAL_NAME"), is("value"));
assertThat(context.getProperty("GO_PROPERTY"), is(nullValue()));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class P4MaterialTest method shouldAddServerSideEnvironmentVariablesClientNameEnvironmentVariable.
@Test
public void shouldAddServerSideEnvironmentVariablesClientNameEnvironmentVariable() throws IOException {
File p4_working_dir = temporaryFolder.newFolder();
P4Material p4 = new P4Material("host:10", "beautiful", "user");
p4.setPassword("loser");
EnvironmentVariableContext envVarCtx;
envVarCtx = new EnvironmentVariableContext();
p4.populateEnvironmentContext(envVarCtx, new MaterialRevision(p4, new Modification("loser", "loserish commit", "loser@boozer.com", new Date(), "123")), p4_working_dir);
assertThat(envVarCtx.getProperty("GO_REVISION"), is("123"));
assertThat(envVarCtx.getProperty("GO_TO_REVISION"), is("123"));
assertThat(envVarCtx.getProperty("GO_FROM_REVISION"), is("123"));
}
use of com.thoughtworks.go.util.command.EnvironmentVariableContext in project gocd by gocd.
the class P4MaterialTest method shouldSetGO_P4_CLIENT_toTheClientName.
@Test
public void shouldSetGO_P4_CLIENT_toTheClientName() {
P4Material material = new P4Material("host:1234", "view", "username", "destination");
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
File agentWorkingDirectory = new File("pipelines/pipeline-name");
material.populateAgentSideEnvironmentContext(environmentVariableContext, agentWorkingDirectory);
assertThat(environmentVariableContext.getProperty("GO_P4_CLIENT_DESTINATION"), is(material.clientName(material.workingdir(agentWorkingDirectory))));
}
Aggregations