use of com.thoughtworks.go.config.materials.PluggableSCMMaterial 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"));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialTest method shouldNotCalculateFingerprintWhenAvailable.
@Test
public void shouldNotCalculateFingerprintWhenAvailable() {
String fingerprint = "fingerprint";
SCM scmConfig = mock(SCM.class);
PluggableSCMMaterial pluggableSCMMaterial = new PluggableSCMMaterial();
pluggableSCMMaterial.setSCMConfig(scmConfig);
pluggableSCMMaterial.setFingerprint(fingerprint);
assertThat(pluggableSCMMaterial.getFingerprint(), is(fingerprint));
verify(scmConfig, never()).getFingerprint();
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialTest method shouldGetAttributesWithoutSecureFields.
@Test
public void shouldGetAttributesWithoutSecureFields() {
PluggableSCMMaterial material = createPluggableSCMMaterialWithSecureConfiguration();
Map<String, Object> attributes = material.getAttributes(false);
assertThat(attributes.get("type"), is("scm"));
assertThat(attributes.get("plugin-id"), is("pluginid"));
Map<String, Object> configuration = (Map<String, Object>) attributes.get("scm-configuration");
assertThat(configuration.get("k1"), is("v1"));
assertThat(configuration.get("k2"), is(nullValue()));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialTest method shouldGetDescription.
@Test
public void shouldGetDescription() {
ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
SCM scmConfig = SCMMother.create("scm-id", "scm-name", "pluginid", "version", new Configuration(k1));
PluggableSCMMaterial material = new PluggableSCMMaterial();
material.setSCMConfig(scmConfig);
assertThat(material.getDescription(), is("scm-name"));
}
use of com.thoughtworks.go.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialTest method shouldReturnTrueForPluggableScmMaterial_supportsDestinationFolder.
@Test
public void shouldReturnTrueForPluggableScmMaterial_supportsDestinationFolder() throws Exception {
PluggableSCMMaterial material = new PluggableSCMMaterial();
assertThat(material.supportsDestinationFolder(), is(true));
}
Aggregations