Search in sources :

Example 11 with FakeBuildRepositoryRemote

use of com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method doWorkWithMaterials.

private EnvironmentVariableContext doWorkWithMaterials(Materials materials) throws IOException {
    pipelineConfig.setMaterialConfigs(materials.convertToConfigs());
    BuildAssignment buildAssigment = createAssignment(null);
    BuildWork work = new BuildWork(buildAssigment, StandardCharsets.UTF_8.name());
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), new GoArtifactsManipulatorStub(), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, null));
    return environmentVariableContext;
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext)

Example 12 with FakeBuildRepositoryRemote

use of com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote in project gocd by gocd.

the class BuildWorkEnvironmentVariablesTest method shouldUseSvnMaterialNameIfPresent.

@Test
public void shouldUseSvnMaterialNameIfPresent() throws IOException {
    svnMaterial.setName(new CaseInsensitiveString("Cruise"));
    pipelineConfig.setMaterialConfigs(new MaterialConfigs(svnMaterial.config()));
    BuildAssignment buildAssigment = createAssignment(null);
    BuildWork work = new BuildWork(buildAssigment, StandardCharsets.UTF_8.name());
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    new SystemEnvironment().setProperty("serviceUrl", "some_random_place");
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), new GoArtifactsManipulatorStub(), new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, null));
    assertThat(environmentVariableContext.getProperty("GO_REVISION_CRUISE"), is("3"));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.jupiter.api.Test)

Aggregations

FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)12 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)12 Test (org.junit.jupiter.api.Test)10 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)7 ArrayList (java.util.ArrayList)7 File (java.io.File)6 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)4 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 URLService (com.thoughtworks.go.util.URLService)1 Test (org.junit.Test)1