fix profile for other tests

This commit is contained in:
Michael Hoennig 2025-01-28 07:17:38 +01:00
parent 8ba4c870b3
commit 9a991c95e7
3 changed files with 7 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import static net.hostsharing.hsadminng.config.HttpHeadersBuilder.headers;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.client.WireMock.*;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestPropertySource(properties = {"server.port=0", "hsadminng.cas.server=http://localhost:8088/cas"}) @TestPropertySource(properties = {"server.port=0", "hsadminng.cas.server=http://localhost:8088/cas"})
@ActiveProfiles("wiremock") // IMPORTANT: To test prod config, do not use test profile! @ActiveProfiles("wiremock") // IMPORTANT: To test prod config, do not use test profile!

View File

@ -74,14 +74,14 @@ import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TE
@DataJpaTest(properties = { @DataJpaTest(properties = {
"spring.liquibase.enabled=false" // @Sql should go first, Liquibase will be initialized programmatically "spring.liquibase.enabled=false" // @Sql should go first, Liquibase will be initialized programmatically
}) })
@ActiveProfiles("only-office") @ActiveProfiles({"only-office", "liquibase-migration-test"})
@TestPropertySource(properties = "spring.liquibase.contexts=only-office") @TestPropertySource(properties = "spring.liquibase.contexts=only-office")
@DirtiesContext @DirtiesContext
@Import({ Context.class, JpaAttempt.class, LiquibaseConfig.class }) @Import({ Context.class, JpaAttempt.class, LiquibaseConfig.class })
@Sql(value = "/db/prod-only-office-schema-with-test-data.sql", executionPhase = BEFORE_TEST_CLASS) @Sql(value = "/db/prod-only-office-schema-with-test-data.sql", executionPhase = BEFORE_TEST_CLASS)
public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport { public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport {
private static final String EXPECTED_CHANGESET = "hs-hosting-SCHEMA"; private static final String EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION = "hs-hosting-SCHEMA";
private static int initialChangeSetCount = 0; private static int initialChangeSetCount = 0;
@Autowired @Autowired
@ -100,7 +100,7 @@ public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport {
void test() { void test() {
final var liquibaseScripts = singleColumnSqlQuery("SELECT id FROM public.databasechangelog"); final var liquibaseScripts = singleColumnSqlQuery("SELECT id FROM public.databasechangelog");
assertThat(liquibaseScripts).hasSizeGreaterThan(initialChangeSetCount); assertThat(liquibaseScripts).hasSizeGreaterThan(initialChangeSetCount);
assertThat(liquibaseScripts).contains(EXPECTED_CHANGESET); assertThat(liquibaseScripts).contains(EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION);
} }
private void assertThatDatabaseIsInitialized() { private void assertThatDatabaseIsInitialized() {
@ -109,7 +109,7 @@ public class LiquibaseCompatibilityIntegrationTest extends CsvDataImport {
final var liquibaseScripts = singleColumnSqlQuery("SELECT * FROM public.databasechangelog"); final var liquibaseScripts = singleColumnSqlQuery("SELECT * FROM public.databasechangelog");
assertThat(liquibaseScripts).hasSizeGreaterThan(285); assertThat(liquibaseScripts).hasSizeGreaterThan(285);
assertThat(liquibaseScripts).doesNotContain(EXPECTED_CHANGESET); assertThat(liquibaseScripts).doesNotContain(EXPECTED_CHANGESET_ONLY_AFTER_NEW_MIGRATION);
initialChangeSetCount = liquibaseScripts.size(); initialChangeSetCount = liquibaseScripts.size();
} }

View File

@ -6,10 +6,12 @@ import liquibase.database.jvm.JdbcConnection;
import liquibase.resource.ClassLoaderResourceAccessor; import liquibase.resource.ClassLoaderResourceAccessor;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import javax.sql.DataSource; import javax.sql.DataSource;
@Configuration @Configuration
@Profile("liquibase-migration-test")
public class LiquibaseConfig { public class LiquibaseConfig {
@Bean @Bean