use of com.thoughtworks.go.config.PluggableArtifactConfig in project gocd by gocd.
the class ArtifactPlanTest method shouldConvertPluggableArtifactConfigToArtifactPlans.
@Test
public void shouldConvertPluggableArtifactConfigToArtifactPlans() {
final PluggableArtifactConfig artifactConfig = new PluggableArtifactConfig("ID", "StoreID", create("Foo", true, "Bar"), create("Baz", false, "Car"));
final ArtifactPlan artifactPlan = new ArtifactPlan(artifactConfig);
assertThat(artifactPlan.getArtifactType(), is(ArtifactType.plugin));
assertThat(artifactPlan.getPluggableArtifactConfiguration().size(), is(3));
assertThat(artifactPlan.getPluggableArtifactConfiguration(), hasEntry("id", "ID"));
assertThat(artifactPlan.getPluggableArtifactConfiguration(), hasEntry("storeId", "StoreID"));
final Map<String, String> configuration = (Map<String, String>) artifactPlan.getPluggableArtifactConfiguration().get("configuration");
assertThat(configuration.size(), is(2));
assertThat(configuration, hasEntry("Foo", "Bar"));
assertThat(configuration, hasEntry("Baz", "Car"));
}
use of com.thoughtworks.go.config.PluggableArtifactConfig in project gocd by gocd.
the class ArtifactsPublisherTest method shouldErrorOutWhenFailedToCreateFolderToWritePluggableArtifactMetadata.
@Test
public void shouldErrorOutWhenFailedToCreateFolderToWritePluggableArtifactMetadata() {
assumeFalse("Do not run on windows.", IS_WINDOWS);
final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString())).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
thrown.expect(RuntimeException.class);
thrown.expectMessage("[go] Could not create pluggable artifact metadata folder");
workingFolder.setWritable(false);
new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(artifactPlan));
}
use of com.thoughtworks.go.config.PluggableArtifactConfig in project gocd by gocd.
the class ArtifactsPublisherTest method shouldNotUploadMetadataFileWhenPublishPluggableArtifactIsUnsuccessful.
@Test
public void shouldNotUploadMetadataFileWhenPublishPluggableArtifactIsUnsuccessful() {
final ArtifactStore artifactStore = new ArtifactStore("s3", "cd.go.s3", create("Foo", false, "Bar"));
final ArtifactStores artifactStores = new ArtifactStores(artifactStore);
final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString())).thenThrow(new RuntimeException("something"));
try {
new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(artifactPlan));
fail("Should throw error for pluggable artifact [installers].");
} catch (Exception e) {
assertThat(publisher.publishedFiles().size(), is(0));
assertThat(e.getMessage(), containsString("[go] Uploading finished. Failed to upload [installers]."));
}
}
use of com.thoughtworks.go.config.PluggableArtifactConfig 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())).thenReturn(new PublishArtifactResponse(Collections.singletonMap("src", "s3://dist")));
when(artifactExtension.publishArtifact(eq("cd.go.docker"), eq(dockerArtifactPlan), eq(dockerArtifactStore), anyString())).thenReturn(new PublishArtifactResponse(Collections.singletonMap("image", "alpine")));
new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(s3ArtifactPlan, dockerArtifactPlan));
assertThat(uploadedPluggableMetadataFiles(publisher.publishedFiles()), containsInAnyOrder("cd.go.s3.json", "cd.go.docker.json"));
}
use of com.thoughtworks.go.config.PluggableArtifactConfig in project gocd by gocd.
the class ArtifactsPublisherTest method shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact.
@Test
public void shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact() {
final ArtifactStore s3ArtifactStore = new ArtifactStore("s3", "cd.go.s3", create("access_key", false, "some-key"));
final ArtifactStores artifactStores = new ArtifactStores(s3ArtifactStore);
final ArtifactPlan s3ArtifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3", create("Baz", true, "Car")));
when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(s3ArtifactPlan), eq(s3ArtifactStore), anyString())).thenReturn(new PublishArtifactResponse(Collections.singletonMap("src", "s3://dist")));
new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(Arrays.asList(s3ArtifactPlan));
InOrder inOrder = inOrder(registry, artifactExtension);
inOrder.verify(registry, times(1)).registerProcessorFor(eq(CONSOLE_LOG.requestName()), any(ArtifactRequestProcessor.class));
inOrder.verify(artifactExtension, times(1)).publishArtifact("cd.go.s3", s3ArtifactPlan, s3ArtifactStore, workingFolder.getAbsolutePath());
inOrder.verify(registry, times(1)).removeProcessorFor(CONSOLE_LOG.requestName());
}
Aggregations