Search in sources :

Example 1 with GoPublisher

use of com.thoughtworks.go.work.GoPublisher in project gocd by gocd.

the class ArtifactsPublisherTest method shouldDeletePluggableArtifactMetadataDirectory.

@Test
public void shouldDeletePluggableArtifactMetadataDirectory() throws Exception {
    TestFileUtil.createTestFile(workingFolder, "installer.zip");
    TestFileUtil.createTestFile(workingFolder, "testreports.xml");
    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")));
    List<ArtifactPlan> artifactPlans = Arrays.asList(new ArtifactPlan(ArtifactPlanType.file, "installer.zip", "dist"), new ArtifactPlan(ArtifactPlanType.unit, "testreports.xml", "testreports"), artifactPlan);
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
    final GoPublisher publisher = mock(GoPublisher.class);
    assertThat(Arrays.asList(workingFolder.list()), containsInAnyOrder("testreports.xml", "installer.zip", "cruise-output"));
    new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(artifactPlans, env);
    assertThat(Arrays.asList(workingFolder.list()), containsInAnyOrder("testreports.xml", "installer.zip", "cruise-output"));
}
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) GoPublisher(com.thoughtworks.go.work.GoPublisher) Test(org.junit.jupiter.api.Test)

Example 2 with GoPublisher

use of com.thoughtworks.go.work.GoPublisher in project gocd by gocd.

the class ArtifactsPublisherTest method shouldAddPluggableArtifactMetadataFileArtifactPlanAtTop.

@Test
public void shouldAddPluggableArtifactMetadataFileArtifactPlanAtTop() throws Exception {
    TestFileUtil.createTestFile(workingFolder, "installer.zip");
    TestFileUtil.createTestFile(workingFolder, "testreports.xml");
    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")));
    List<ArtifactPlan> artifactPlans = Arrays.asList(new ArtifactPlan(ArtifactPlanType.file, "installer.zip", "dist"), new ArtifactPlan(ArtifactPlanType.unit, "testreports.xml", "testreports"), artifactPlan);
    when(artifactExtension.publishArtifact(eq("cd.go.s3"), eq(artifactPlan), eq(artifactStore), anyString(), eq(env))).thenReturn(new PublishArtifactResponse(Collections.singletonMap("Foo", "Bar")));
    final GoPublisher publisher = mock(GoPublisher.class);
    new ArtifactsPublisher(publisher, artifactExtension, artifactStores, registry, workingFolder).publishArtifacts(artifactPlans, env);
    InOrder inOrder = inOrder(publisher);
    inOrder.verify(publisher).upload(any(), eq("pluggable-artifact-metadata"));
    inOrder.verify(publisher).upload(any(), eq("dist"));
    inOrder.verify(publisher).upload(any(), eq("testreports"));
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactStores(com.thoughtworks.go.config.ArtifactStores) InOrder(org.mockito.InOrder) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) PublishArtifactResponse(com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse) GoPublisher(com.thoughtworks.go.work.GoPublisher) Test(org.junit.jupiter.api.Test)

Aggregations

ArtifactStore (com.thoughtworks.go.config.ArtifactStore)2 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)2 PluggableArtifactConfig (com.thoughtworks.go.config.PluggableArtifactConfig)2 PublishArtifactResponse (com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse)2 GoPublisher (com.thoughtworks.go.work.GoPublisher)2 Test (org.junit.jupiter.api.Test)2 InOrder (org.mockito.InOrder)1