use of com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote in project gocd by gocd.
the class BuildWorkEnvironmentVariablesTest method shouldOutputEnvironmentVariablesIntoConsoleOut.
@Test
public void shouldOutputEnvironmentVariablesIntoConsoleOut() throws IOException {
BuildAssignment buildAssigment = createAssignment(null);
BuildWork work = new BuildWork(buildAssigment, StandardCharsets.UTF_8.name());
GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
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(), manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, null));
assertThat(manipulator.consoleOut(), printedEnvVariable("GO_SERVER_URL", "some_random_place"));
assertThat(manipulator.consoleOut(), printedEnvVariable("GO_PIPELINE_NAME", PIPELINE_NAME));
assertThat(manipulator.consoleOut(), printedEnvVariable("GO_PIPELINE_COUNTER", 1));
assertThat(manipulator.consoleOut(), printedEnvVariable("GO_PIPELINE_LABEL", 1));
assertThat(manipulator.consoleOut(), printedEnvVariable("GO_STAGE_NAME", STAGE_NAME));
assertThat(manipulator.consoleOut(), printedEnvVariable("GO_STAGE_COUNTER", 1));
assertThat(manipulator.consoleOut(), printedEnvVariable("GO_JOB_NAME", JOB_NAME));
assertThat(manipulator.consoleOut(), printedEnvVariable("GO_REVISION", 3));
assertThat(manipulator.consoleOut(), printedEnvVariable("GO_TRIGGER_USER", TRIGGERED_BY_USER));
}
use of com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldUploadMatchedFolder.
@Test
public void shouldUploadMatchedFolder() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, "**/*", "mypic"));
BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic/fail.png", "logs/pic/pass.png", "README" });
BuildWork work = new BuildWork(buildAssigment, StandardCharsets.UTF_8.name());
GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic/fail.png"), "mypic/logs/pic")));
assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic/pass.png"), "mypic/logs/pic")));
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic"), "mypic/logs"));
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/README"), "mypic"));
}
use of com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldUploadEachMatchedFile.
@Test
public void shouldUploadEachMatchedFile() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, "**/*.png", "mypic"));
BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic/fail.png", "logs/pic/pass.png", "README" });
BuildWork work = new BuildWork(buildAssigment, StandardCharsets.UTF_8.name());
GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic/pass.png"), "mypic/logs/pic"));
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic/fail.png"), "mypic/logs/pic"));
}
use of com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldUploadFolderWhenDirectMatch.
@Test
public void shouldUploadFolderWhenDirectMatch() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, "logs/pic-1", "mypic"));
BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic-1/fail.png", "logs/pic-1/pass.png", "logs/pic-2/cancel.png", "logs/pic-2/complete.png", "README" });
BuildWork work = new BuildWork(buildAssigment, StandardCharsets.UTF_8.name());
GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1"), "mypic"));
}
use of com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote in project gocd by gocd.
the class BuildWorkArtifactUploadingTest method shouldUploadFolderWhenTrimedPathDirectMatch.
@Test
public void shouldUploadFolderWhenTrimedPathDirectMatch() throws Exception {
List<ArtifactPlan> artifactPlans = new ArrayList<>();
artifactPlans.add(new ArtifactPlan(ArtifactPlanType.file, "logs/pic-1 ", "mypic"));
BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic-1/fail.png", "logs/pic-1/pass.png", "logs/pic-2/cancel.png", "logs/pic-2/complete.png", "README" });
BuildWork work = new BuildWork(buildAssigment, StandardCharsets.UTF_8.name());
GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
work.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry));
List<UploadEntry> entries = manipulator.uploadEntries();
assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1"), "mypic"));
}
Aggregations