Search in sources :

Example 6 with UploadEntry

use of com.thoughtworks.go.matchers.UploadEntry in project gocd by gocd.

the class BuildWorkArtifactUploadingTest method shouldUploadMatchedFolder.

@Test
public void shouldUploadMatchedFolder() throws Exception {
    ArtifactPlans artifactPlans = new ArtifactPlans();
    artifactPlans.add(new ArtifactPlan("**/*", "mypic"));
    BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic/fail.png", "logs/pic/pass.png", "README" });
    BuildWork work = new BuildWork(buildAssigment);
    GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, environmentVariableContext, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension);
    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"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) File(java.io.File) Test(org.junit.Test)

Example 7 with UploadEntry

use of com.thoughtworks.go.matchers.UploadEntry in project gocd by gocd.

the class BuildWorkArtifactUploadingTest method shouldUploadFolderWhenMatchedWithWildCards.

@Test
public void shouldUploadFolderWhenMatchedWithWildCards() throws Exception {
    ArtifactPlans artifactPlans = new ArtifactPlans();
    artifactPlans.add(new ArtifactPlan("logs/pic-*", "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);
    GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, environmentVariableContext, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension);
    List<UploadEntry> entries = manipulator.uploadEntries();
    assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1/pass.png"), "mypic")));
    assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1/fail.png"), "mypic")));
    assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-2/cancel.png"), "mypic")));
    assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-2/complete.png"), "mypic")));
    assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-1"), "mypic"));
    assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic-2"), "mypic"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) File(java.io.File) Test(org.junit.Test)

Example 8 with UploadEntry

use of com.thoughtworks.go.matchers.UploadEntry in project gocd by gocd.

the class BuildWorkArtifactUploadingTest method shouldNotUploadFileContainingFolderAgain.

@Test
public void shouldNotUploadFileContainingFolderAgain() throws Exception {
    ArtifactPlans artifactPlans = new ArtifactPlans();
    artifactPlans.add(new ArtifactPlan("logs/pic/*.png", "mypic"));
    BuildAssignment buildAssigment = createAssignment(artifactPlans, new String[] { "logs/pic/fail.png", "logs/pic/pass.png", "README" });
    BuildWork work = new BuildWork(buildAssigment);
    GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(agentIdentifier, new FakeBuildRepositoryRemote(), manipulator, environmentVariableContext, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension);
    List<UploadEntry> entries = manipulator.uploadEntries();
    assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic/pass.png"), "mypic"));
    assertThat(entries, uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic/fail.png"), "mypic"));
    assertThat(entries, not(uploadFileToDestination(new File(buildWorkingDirectory.getPath() + "/logs/pic"), "mypic")));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) FakeBuildRepositoryRemote(com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) File(java.io.File) Test(org.junit.Test)

Example 9 with UploadEntry

use of com.thoughtworks.go.matchers.UploadEntry in project gocd by gocd.

the class BuildWorkArtifactUploadingTest method shouldFailBuildWhenSourceDirectoryDoesNotExist.

@Test
public void shouldFailBuildWhenSourceDirectoryDoesNotExist() throws Exception {
    ArtifactPlans artifactPlans = new ArtifactPlans();
    artifactPlans.add(new ArtifactPlan("not-Exist-Folder", "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);
    GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
    BuildRepositoryRemoteStub repository = new BuildRepositoryRemoteStub();
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(agentIdentifier, repository, manipulator, environmentVariableContext, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension);
    List<UploadEntry> entries = manipulator.uploadEntries();
    assertThat(entries.size(), is(0));
    assertThat(repository.states, containsResult(JobState.Building));
    assertThat(repository.states, containsResult(JobState.Completing));
    assertThat(repository.results, containsResult(JobResult.Failed));
    assertThat(manipulator.consoleOut(), printedRuleDoesNotMatchFailure(buildWorkingDirectory.getPath(), "not-Exist-Folder"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Example 10 with UploadEntry

use of com.thoughtworks.go.matchers.UploadEntry in project gocd by gocd.

the class BuildWorkArtifactUploadingTest method shouldFailBuildWhenNothingMatched.

@Test
public void shouldFailBuildWhenNothingMatched() throws Exception {
    ArtifactPlans artifactPlans = new ArtifactPlans();
    artifactPlans.add(new ArtifactPlan("logs/picture", "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);
    GoArtifactsManipulatorStub manipulator = new GoArtifactsManipulatorStub();
    BuildRepositoryRemoteStub repository = new BuildRepositoryRemoteStub();
    AgentIdentifier agentIdentifier = new AgentIdentifier("somename", "127.0.0.1", AGENT_UUID);
    work.doWork(agentIdentifier, repository, manipulator, environmentVariableContext, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie", false), packageRepositoryExtension, scmExtension, taskExtension);
    List<UploadEntry> entries = manipulator.uploadEntries();
    assertThat(entries.size(), is(0));
    assertThat(repository.states, containsResult(JobState.Building));
    assertThat(repository.states, containsResult(JobState.Completing));
    assertThat(repository.results, containsResult(JobResult.Failed));
    assertThat(manipulator.consoleOut(), printedRuleDoesNotMatchFailure(buildWorkingDirectory.getPath(), "logs/picture"));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) UploadEntry(com.thoughtworks.go.matchers.UploadEntry) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Aggregations

UploadEntry (com.thoughtworks.go.matchers.UploadEntry)11 AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)10 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)10 Test (org.junit.Test)10 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)7 File (java.io.File)6 URLService (com.thoughtworks.go.util.URLService)1