Search in sources :

Example 21 with ConsoleResult

use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.

the class P4OutputParserTest method shouldParseCommentWithAffectedFilesCorrectly.

@Test
void shouldParseCommentWithAffectedFilesCorrectly() throws P4OutputParseException {
    String description = "Change 5 by cceuser@CceDev01 on 2009/08/06 14:21:30\n" + "\n" + "\tAffected files ...\n" + "\t\n" + "\t... //DEPOT/FILE#943 edit\n" + "\n" + "Affected files ...\n" + "\n" + "... //depot/file#5 edit";
    Modification modification = parser.modificationFromDescription(description, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
    assertThat(modification.getComment()).isEqualTo("Affected files ...\n" + "\n" + "... //DEPOT/FILE#943 edit");
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 22 with ConsoleResult

use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.

the class P4OutputParserTest method shouldMatchWhenCommentsAreMultipleLines.

@Test
void shouldMatchWhenCommentsAreMultipleLines() throws P4OutputParseException, ParseException {
    Modification modification = parser.modificationFromDescription(BUG_2503_OUTPUT, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
    assertThat(parser.revisionFromChange(BUG_2503_OUTPUT)).isEqualTo(122636L);
    assertThat(modification.getModifiedTime()).isEqualTo(DESCRIPTION_FORMAT.parse("2009/02/06 17:53:57"));
    assertThat(modification.getModifiedFiles().size()).isEqualTo(1);
    assertThat(modification.getUserName()).isEqualTo("ipaipa@ipaipa-STANDARD-DHTML");
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 23 with ConsoleResult

use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.

the class P4OutputParserTest method shouldThrowExceptionWhenCannotParseChanges.

@Test
void shouldThrowExceptionWhenCannotParseChanges() {
    String line = "Some line I don't understand";
    try {
        parser.modificationFromDescription(line, new ConsoleResult(0, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>()));
        fail("Should throw exception if can't parse the description");
    } catch (P4OutputParseException expected) {
        assertThat(expected.getMessage()).contains(line);
    }
}
Also used : ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 24 with ConsoleResult

use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.

the class GoConfigRepoConfigDataSourceIntegrationTest method setupExternalConfigRepo.

private String setupExternalConfigRepo(File configRepo, String configRepoTestResource) throws IOException {
    ClassPathResource resource = new ClassPathResource(configRepoTestResource);
    FileUtils.copyDirectory(resource.getFile(), configRepo);
    CommandLine.createCommandLine("git").withEncoding("utf-8").withArg("init").withArg(configRepo.getAbsolutePath()).runOrBomb(null);
    CommandLine.createCommandLine("git").withEncoding("utf-8").withArgs("config", "commit.gpgSign", "false").withWorkingDir(configRepo.getAbsoluteFile()).runOrBomb(null);
    gitAddDotAndCommit(configRepo);
    ConsoleResult consoleResult = CommandLine.createCommandLine("git").withEncoding("utf-8").withArg("log").withArg("-1").withArg("--pretty=format:%h").withWorkingDir(configRepo).runOrBomb(null);
    return consoleResult.outputAsString();
}
Also used : ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) ClassPathResource(org.springframework.core.io.ClassPathResource)

Aggregations

ConsoleResult (com.thoughtworks.go.util.command.ConsoleResult)24 Test (org.junit.jupiter.api.Test)12 Modification (com.thoughtworks.go.domain.materials.Modification)11 ArrayList (java.util.ArrayList)10 CommandLine (com.thoughtworks.go.util.command.CommandLine)5 Test (org.junit.Test)5 ClassPathResource (org.springframework.core.io.ClassPathResource)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)1 LogFixture (com.thoughtworks.go.util.LogFixture)1 CommandLineException (com.thoughtworks.go.util.command.CommandLineException)1 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)1 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)1 StringWriter (java.io.StringWriter)1 DateTime (org.joda.time.DateTime)1