Search in sources :

Example 36 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.

the class SvnCommandTest method shouldRecogniseSvnAsTheSameIfURLContainsSpaces.

@Test
@DisabledOnOs(OS.WINDOWS)
void shouldRecogniseSvnAsTheSameIfURLContainsSpaces() throws Exception {
    File working = TempDirUtils.createTempDirectoryIn(tempDir, "shouldRecogniseSvnAsTheSameIfURLContainsSpaces").toFile();
    SvnTestRepo repo = new SvnTestRepo(tempDir, "a directory with spaces");
    SvnMaterial material = repo.material();
    assertThat(material.getUrl()).contains("%20");
    InMemoryStreamConsumer output = new InMemoryStreamConsumer();
    material.freshCheckout(output, new SubversionRevision("3"), working);
    assertThat(output.getAllOutput()).contains("Checked out revision 3");
    InMemoryStreamConsumer output2 = new InMemoryStreamConsumer();
    material.updateTo(output2, working, new RevisionContext(new SubversionRevision("4")), new TestSubprocessExecutionContext());
    assertThat(output2.getAllOutput()).contains("Updated to revision 4");
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) SvnTestRepo(com.thoughtworks.go.helper.SvnTestRepo) File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 37 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.

the class SvnCommandTest method shouldRecogniseSvnAsTheSameIfURLUsesFileProtocol.

@Test
@DisabledOnOs(OS.WINDOWS)
void shouldRecogniseSvnAsTheSameIfURLUsesFileProtocol() throws Exception {
    SvnTestRepo repo = new SvnTestRepo(tempDir);
    File working = TempDirUtils.createTempDirectoryIn(tempDir, "someDir").toFile();
    SvnMaterial material = repo.material();
    InMemoryStreamConsumer output = new InMemoryStreamConsumer();
    material.freshCheckout(output, new SubversionRevision("3"), working);
    assertThat(output.getAllOutput()).contains("Checked out revision 3");
    InMemoryStreamConsumer output2 = new InMemoryStreamConsumer();
    updateMaterial(material, new SubversionRevision("4"), working, output2);
    assertThat(output2.getAllOutput()).contains("Updated to revision 4");
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) SvnTestRepo(com.thoughtworks.go.helper.SvnTestRepo) File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 38 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.

the class CommandLineTest method shouldBeAbleToSpecifyEncoding.

@Test
@DisabledOnOs(OS.WINDOWS)
void shouldBeAbleToSpecifyEncoding() {
    String chrisWasHere = "?????";
    CommandLine line = CommandLine.createCommandLine("echo").withArg(chrisWasHere).withEncoding("UTF-8");
    InMemoryStreamConsumer output = new InMemoryStreamConsumer();
    ProcessWrapper processWrapper = line.execute(output, new EnvironmentVariableContext(), null);
    processWrapper.waitForExit();
    assertThat(output.getAllOutput(), containsString(chrisWasHere));
}
Also used : ProcessWrapper(com.thoughtworks.go.util.ProcessWrapper) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 39 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.

the class CommandLineTest method shouldBeAbleToRunCommandsInSubdirectoriesWithNoWorkingDir.

@Test
@DisabledOnOs(OS.WINDOWS)
void shouldBeAbleToRunCommandsInSubdirectoriesWithNoWorkingDir() throws IOException {
    File shellScript = createScriptInSubFolder("hello-world.sh", "echo 'Hello World!'");
    assertThat(shellScript.setExecutable(true), is(true));
    CommandLine line = CommandLine.createCommandLine("subFolder/hello-world.sh").withWorkingDir(temporaryFolder.toFile()).withEncoding("utf-8");
    InMemoryStreamConsumer out = new InMemoryStreamConsumer();
    line.execute(out, new EnvironmentVariableContext(), null).waitForExit();
    assertThat(out.getAllOutput(), containsString("Hello World!"));
}
Also used : File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 40 with DisabledOnOs

use of org.junit.jupiter.api.condition.DisabledOnOs in project gocd by gocd.

the class CommandLineTest method shouldNotLogPasswordsOnExceptionThrown.

@Test
@DisabledOnOs(OS.WINDOWS)
void shouldNotLogPasswordsOnExceptionThrown() throws IOException {
    File file = Files.writeString(temporaryFolder.resolve("test.sh"), "echo $1 && exit 10", UTF_8).toFile();
    CommandLine line = CommandLine.createCommandLine("/bin/sh").withArg(file.getAbsolutePath()).withArg(new PasswordArgument("secret")).withEncoding("utf-8");
    assertThatThrownBy(() -> line.runOrBomb(null)).isExactlyInstanceOf(CommandLineException.class).hasMessageContaining("EXIT CODE (10)").hasMessageNotContaining("secret");
}
Also used : File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Aggregations

DisabledOnOs (org.junit.jupiter.api.condition.DisabledOnOs)85 Test (org.junit.jupiter.api.Test)78 Path (java.nio.file.Path)38 File (java.io.File)24 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 PathsBaseTest (org.assertj.core.internal.PathsBaseTest)12 AssertionsUtil.expectAssertionError (org.assertj.core.util.AssertionsUtil.expectAssertionError)11 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)6 PageSwapperFactory (org.neo4j.io.pagecache.PageSwapperFactory)6 PageSwapperTest (org.neo4j.io.pagecache.PageSwapperTest)6 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)5 DelegatingStoreChannel (org.neo4j.io.fs.DelegatingStoreChannel)5 StoreChannel (org.neo4j.io.fs.StoreChannel)5 DisabledForRoot (org.neo4j.test.extension.DisabledForRoot)5 Closeable (java.io.Closeable)4 URI (java.net.URI)4 FileUtils.writeByteArrayToFile (org.apache.commons.io.FileUtils.writeByteArrayToFile)4 ShouldBeFile.shouldBeFile (org.assertj.core.error.ShouldBeFile.shouldBeFile)4 FilesBaseTest (org.assertj.core.internal.FilesBaseTest)4 Files.newFile (org.assertj.core.util.Files.newFile)4