Search in sources :

Example 11 with PublishArtifactResponse

use of com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse in project gocd by gocd.

the class ArtifactsPublisherTest method shouldPublishPluggableArtifactsAndUploadMetadataFileToServer.

@Test
public void shouldPublishPluggableArtifactsAndUploadMetadataFileToServer() throws IOException {
    final ArtifactStore s3ArtifactStore = new ArtifactStore("s3", "cd.go.s3", create("access_key", false, "some-key"));
    final ArtifactStore dockerArtifactStore = new ArtifactStore("docker", "cd.go.docker", create("registry-url", false, "docker.io"));
    final ArtifactStores artifactStores = new ArtifactStores(s3ArtifactStore, dockerArtifactStore);
    final ArtifactPlan s3ArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
    final ArtifactPlan dockerArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("test-reports", "docker", create("junit", false, "junit.xml")));
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(s3ArtifactPlan), eq(s3ArtifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("src", "s3://dist")));
    when(artifactExtension.publishArtifact(eq("cd.go.docker"), eq(dockerArtifactPlan), eq(dockerArtifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("image", "alpine")));
    new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(s3ArtifactPlan, dockerArtifactPlan), env);
    assertThat(uploadedPluggableMetadataFiles(publisher.publishedFiles()), containsInAnyOrder("cd.go.s3.json", "cd.go.docker.json"));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) PublishArtifactResponse(com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse) Test(org.junit.jupiter.api.Test)

Aggregations

PublishArtifactResponse (com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse)11 ArtifactStore (com.thoughtworks.go.config.ArtifactStore)8 Test (org.junit.jupiter.api.Test)8 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)6 PluggableArtifactConfig (com.thoughtworks.go.config.PluggableArtifactConfig)6 ArtifactPlan (com.thoughtworks.go.domain.ArtifactPlan)2 GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)2 GoPublisher (com.thoughtworks.go.work.GoPublisher)2 InOrder (org.mockito.InOrder)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)1 IOException (java.io.IOException)1 Test (org.junit.Test)1