use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class BuildAssignmentTest method shouldCopyAdditionalDataToBuildAssignment.
@Test
void shouldCopyAdditionalDataToBuildAssignment() {
MaterialRevision packageMaterialRevision = ModificationsMother.createPackageMaterialRevision("revision");
Map<String, String> additionalData = new HashMap<>();
additionalData.put("a1", "v1");
additionalData.put("a2", "v2");
String additionalDataAsString = new Gson().toJson(additionalData);
packageMaterialRevision.getModifications().first().setAdditionalData(additionalDataAsString);
MaterialRevisions materialRevisions = new MaterialRevisions(packageMaterialRevision);
BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, "user1");
BuildAssignment buildAssignment = BuildAssignment.create(jobForPipeline("foo"), buildCause, new ArrayList<>(), null, null, new ArtifactStores());
assertThat(buildAssignment.getBuildApprover()).isEqualTo("user1");
assertThat(buildAssignment.materialRevisions().getRevisions().size()).isEqualTo(materialRevisions.getRevisions().size());
assertRevisions(buildAssignment, packageMaterialRevision);
Modification actualModification = buildAssignment.materialRevisions().getRevisions().get(0).getModification(0);
assertThat(actualModification.getAdditionalData()).isEqualTo(additionalDataAsString);
assertThat(actualModification.getAdditionalDataMap()).isEqualTo(additionalData);
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class BuildAssignmentTest method shouldNotHaveReferenceToModifiedFilesSinceLargeCommitsCouldCauseBothServerAndAgentsToRunOutOfMemory_MoreoverThisInformationIsNotRequiredOnAgentSide.
@Test
void shouldNotHaveReferenceToModifiedFilesSinceLargeCommitsCouldCauseBothServerAndAgentsToRunOutOfMemory_MoreoverThisInformationIsNotRequiredOnAgentSide() {
List<Modification> modificationsForSvn = ModificationsMother.multipleModificationList();
List<Modification> modificationsForHg = ModificationsMother.multipleModificationList();
MaterialRevision svn = new MaterialRevision(svnMaterial(), modificationsForSvn);
MaterialRevision hg = new MaterialRevision(hgMaterial(), modificationsForHg);
MaterialRevisions materialRevisions = new MaterialRevisions(svn, hg);
BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, "user1");
BuildAssignment buildAssignment = BuildAssignment.create(jobForPipeline("foo"), buildCause, new ArrayList<>(), null, null, new ArtifactStores());
assertThat(buildAssignment.getBuildApprover()).isEqualTo("user1");
assertThat(buildAssignment.materialRevisions().getRevisions().size()).isEqualTo(materialRevisions.getRevisions().size());
assertRevisions(buildAssignment, svn);
assertRevisions(buildAssignment, hg);
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class BuildAssignmentTest method shouldInitializeEnvironmentContextFromJobPlan.
@Test
void shouldInitializeEnvironmentContextFromJobPlan() {
DefaultJobPlan defaultJobPlan = jobForPipeline("foo");
EnvironmentVariables variables = new EnvironmentVariables();
variables.add("key1", "value1");
variables.add("key2", "value2");
defaultJobPlan.setVariables(variables);
BuildAssignment buildAssignment = BuildAssignment.create(defaultJobPlan, BuildCause.createManualForced(), new ArrayList<>(), null, null, new ArtifactStores());
EnvironmentVariableContext context = buildAssignment.initialEnvironmentVariableContext();
assertThat(context.getProperties().size()).isEqualTo(9);
assertThat(context.getProperty("key1")).isEqualTo("value1");
assertThat(context.getProperty("key2")).isEqualTo("value2");
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class BuildAssignmentTest method shouldIntializeEnvironmentContextWithJobPlanEnvironmentVariablesOveridingEnvVariablesFromTheEnvironment.
@Test
void shouldIntializeEnvironmentContextWithJobPlanEnvironmentVariablesOveridingEnvVariablesFromTheEnvironment() {
DefaultJobPlan defaultJobPlan = jobForPipeline("foo");
EnvironmentVariables variables = new EnvironmentVariables();
variables.add("key1", "value_from_job_plan");
variables.add("key2", "value2");
defaultJobPlan.setVariables(variables);
EnvironmentVariableContext contextFromEnvironment = new EnvironmentVariableContext("key1", "value_from_environment");
contextFromEnvironment.setProperty("key3", "value3", false);
BuildAssignment buildAssignment = BuildAssignment.create(defaultJobPlan, BuildCause.createManualForced(), new ArrayList<>(), null, contextFromEnvironment, new ArtifactStores());
EnvironmentVariableContext context = buildAssignment.initialEnvironmentVariableContext();
assertThat(context.getProperties().size()).isEqualTo(10);
assertThat(context.getProperty("key1")).isEqualTo("value_from_job_plan");
assertThat(context.getProperty("key2")).isEqualTo("value2");
assertThat(context.getProperty("key3")).isEqualTo("value3");
}
use of com.thoughtworks.go.config.ArtifactStores in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method createAssignment.
private BuildAssignment createAssignment(List<ArtifactPlan> artifactPlans, String[] fileToCreate) throws IOException {
MaterialRevisions materialRevisions = materialRevisions();
BuildCause buildCause = BuildCause.createWithModifications(materialRevisions, "");
List<Builder> builders = new ArrayList<>();
builders.add(new CreateFileBuilder(fileToCreate));
DefaultJobPlan plan = new DefaultJobPlan(new Resources(), artifactPlans, -1, new JobIdentifier(PIPELINE_NAME, -2, "1", STAGE_NAME, "1", JOB_NAME), null, new EnvironmentVariables(), new EnvironmentVariables(), null, null);
return BuildAssignment.create(plan, buildCause, builders, buildWorkingDirectory, new EnvironmentVariableContext(), new ArtifactStores());
}
Aggregations