Search in sources :

Example 11 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.

the class ArtifactPlanTest method shouldErrorOutWhenDuplicateArtifactPlansExists.

@Test
public void shouldErrorOutWhenDuplicateArtifactPlansExists() {
    List<ArtifactPlan> plans = new ArrayList<>();
    ArtifactPlan existingPlan = new ArtifactPlan("src", "dest");
    plans.add(existingPlan);
    ArtifactPlan artifactPlan = new ArtifactPlan("src", "dest");
    artifactPlan.validateUniqueness(plans);
    assertThat(artifactPlan.errors().isEmpty(), is(false));
    assertThat(artifactPlan.errors().on(ArtifactPlan.SRC), is("Duplicate artifacts defined."));
    assertThat(artifactPlan.errors().on(ArtifactPlan.DEST), is("Duplicate artifacts defined."));
    assertThat(existingPlan.errors().isEmpty(), is(false));
    assertThat(existingPlan.errors().on(ArtifactPlan.SRC), is("Duplicate artifacts defined."));
    assertThat(existingPlan.errors().on(ArtifactPlan.DEST), is("Duplicate artifacts defined."));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 12 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.

the class ArtifactPlanTest method shouldNormalizePath.

@Test
public void shouldNormalizePath() throws Exception {
    ArtifactPlan artifactPlan = new ArtifactPlan("folder\\src", "folder\\dest");
    assertThat(artifactPlan.getSrc(), is("folder/src"));
    assertThat(artifactPlan.getDest(), is("folder/dest"));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) Test(org.junit.Test)

Example 13 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.

the class ArtifactPlanTest method shouldProvideAppendFilePathToDestWhenPathMatchingAtTheRoot.

@Test
public void shouldProvideAppendFilePathToDestWhenPathMatchingAtTheRoot() {
    ArtifactPlan artifactPlan = new ArtifactPlan("*.jar", "logs");
    assertThat(artifactPlan.destURL(new File("pipelines/pipelineA"), new File("pipelines/pipelineA/a.jar")), is("logs"));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) File(java.io.File) Test(org.junit.Test)

Example 14 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.

the class ArtifactPlanTest method shouldPublishArtifacts.

@Test
public void shouldPublishArtifacts() throws Exception {
    final DefaultGoPublisher publisher = context.mock(DefaultGoPublisher.class);
    final ArtifactPlan artifactPlan = new ArtifactPlan("src", "dest");
    context.checking(new Expectations() {

        {
            one(publisher).upload(new File(testFolder, "src"), "dest");
        }
    });
    artifactPlan.publish(publisher, testFolder);
    context.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) DefaultGoPublisher(com.thoughtworks.go.work.DefaultGoPublisher) File(java.io.File) Test(org.junit.Test)

Example 15 with ArtifactPlan

use of com.thoughtworks.go.config.ArtifactPlan in project gocd by gocd.

the class ArtifactPlanTest method validate_shouldFailIfDestDoesNotMatchAFilePattern.

@Test
public void validate_shouldFailIfDestDoesNotMatchAFilePattern() {
    ArtifactPlan artifactPlan = new ArtifactPlan("foo/bar", "..");
    artifactPlan.validate(null);
    assertThat(artifactPlan.errors().on(ArtifactPlan.DEST), is("Invalid destination path. Destination path should match the pattern (([.]\\/)?[.][^. ]+)|([^. ].+[^. ])|([^. ][^. ])|([^. ])"));
}
Also used : ArtifactPlan(com.thoughtworks.go.config.ArtifactPlan) Test(org.junit.Test)

Aggregations

ArtifactPlan (com.thoughtworks.go.config.ArtifactPlan)29 Test (org.junit.Test)25 TestArtifactPlan (com.thoughtworks.go.config.TestArtifactPlan)15 ArtifactPlans (com.thoughtworks.go.config.ArtifactPlans)8 File (java.io.File)7 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 Cloner (com.rits.cloning.Cloner)1 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)1 JobConfig (com.thoughtworks.go.config.JobConfig)1 Resource (com.thoughtworks.go.config.Resource)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 JobPlan (com.thoughtworks.go.domain.JobPlan)1 Property (com.thoughtworks.go.domain.Property)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)1 Document (org.dom4j.Document)1 Element (org.dom4j.Element)1 DOMDocument (org.dom4j.dom.DOMDocument)1 DOMElement (org.dom4j.dom.DOMElement)1