testcontainers-java

Форк
0
37 строк · 1.8 Кб
1
package org.testcontainers.jdbc;
2

3
import org.junit.Test;
4
import org.testcontainers.containers.Container;
5
import org.testcontainers.containers.JdbcDatabaseContainer;
6

7
import java.sql.Connection;
8
import java.sql.DriverManager;
9

10
import static org.assertj.core.api.Assertions.assertThat;
11

12
/**
13
 * This test belongs in the jdbc module, as it is focused on testing the behaviour of {@link org.testcontainers.containers.JdbcDatabaseContainer}.
14
 * However, the need to use the {@link org.testcontainers.containers.PostgreSQLContainerProvider} (due to the jdbc:tc:postgresql) URL forces it to live here in
15
 * the mysql module, to avoid circular dependencies.
16
 * TODO: Move to the jdbc module and either (a) implement a barebones {@link org.testcontainers.containers.JdbcDatabaseContainerProvider} for testing, or (b) refactor into a unit test.
17
 */
18
public class DatabaseDriverTmpfsTest {
19

20
    @Test
21
    public void testDatabaseHasTmpFsViaConnectionString() throws Exception {
22
        final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename?TC_TMPFS=/testtmpfs:rw";
23
        try (Connection ignored = DriverManager.getConnection(jdbcUrl)) {
24
            JdbcDatabaseContainer<?> container = ContainerDatabaseDriver.getContainer(jdbcUrl);
25
            // check file doesn't exist
26
            String path = "/testtmpfs/test.file";
27
            Container.ExecResult execResult = container.execInContainer("ls", path);
28
            assertThat(execResult.getExitCode())
29
                .as("tmpfs inside container doesn't have file that doesn't exist")
30
                .isNotZero();
31
            // touch && check file does exist
32
            container.execInContainer("touch", path);
33
            execResult = container.execInContainer("ls", path);
34
            assertThat(execResult.getExitCode()).as("tmpfs inside container has file that does exist").isZero();
35
        }
36
    }
37
}
38

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.