Fix test errors (#31)

* test: disable `ActivityImageService` manual test class in default build

The test method was already disabled, but the Spring test context for the class was still being created during the regular test run. Moving `@Disabled` to the class prevents the Testcontainers-based application context from loading for this manual-only test and stops `verify` from failing.

Signed-off-by: Marcus Fihlon <marcus@fihlon.swiss>

* fix: handle missing timezone in activity title generation

Default title generation could fail when parsed activity data had no timezone set. This change adds a null/blank fallback in `ActivityFormatter` so titles can still be generated without throwing a `NullPointerException`.

Signed-off-by: Marcus Fihlon <marcus@fihlon.swiss>

* fix(testcontainers): align versions and stabilize PostGIS setup

Unify Testcontainers dependencies to a consistent version and remove
custom container tweaks that caused instability with Podman.

- align all Testcontainers dependencies to 2.0.5
- remove `HostPortWaitStrategy` (PostgreSQLContainer already defines an appropriate wait strategy)
- remove `withReuse(true)` (may retain state across runs and break reproducibility)

Signed-off-by: Marcus Fihlon <marcus@fihlon.swiss>

---------

Signed-off-by: Marcus Fihlon <marcus@fihlon.swiss>
This commit is contained in:
Marcus Fihlon 2026-05-05 11:34:23 +02:00 committed by GitHub
parent de1b0d56f4
commit b88e6b0a95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 10 deletions

View file

@ -23,7 +23,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<jjwt.version>0.12.3</jjwt.version>
<testcontainers.version>2.0.3</testcontainers.version>
<testcontainers.version>2.0.5</testcontainers.version>
</properties>
<dependencies>
@ -170,15 +170,14 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<version>2.0.2</version>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-postgresql</artifactId>
<version>2.0.1</version>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
@ -193,4 +192,4 @@
</plugins>
</build>
</project>
</project>

View file

@ -98,6 +98,10 @@ public class ActivityFormatter {
*
*/
private static LocalDateTime getUtcDateTimeInZone(LocalDateTime utcDateTime, String timezone) {
if (timezone == null || timezone.isBlank()) {
return utcDateTime;
}
try {
return utcDateTime.atZone(ZoneOffset.UTC)
.withZoneSameInstant(ZoneId.of(timezone))

View file

@ -4,7 +4,6 @@ import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
import org.testcontainers.utility.DockerImageName;
/**
@ -23,8 +22,6 @@ public class TestcontainersConfiguration {
)
.withDatabaseName("testdb")
.withUsername("test")
.withPassword("test")
.waitingFor(new HostPortWaitStrategy())
.withReuse(true);
.withPassword("test");
}
}

View file

@ -27,12 +27,16 @@ import static org.junit.jupiter.api.Assertions.*;
/**
* Manual test for ActivityImageService.
* These tests are disabled by default and should only be run manually.
*
* To run this test manually:
* mvn test -Dtest=ActivityImageServiceTest
*/
@SpringBootTest(properties = {
"fitpub.image.osm-tiles.enabled=true"
})
@ActiveProfiles("test")
@Import(TestcontainersConfiguration.class)
@Disabled("Manual test - run explicitly when needed")
class ActivityImageServiceTest {
@Autowired
@ -55,7 +59,6 @@ class ActivityImageServiceTest {
* mvn test -Dtest=ActivityImageServiceTest#testGenerateActivityImage_Manual
*/
@Test
@Disabled("Manual test - run explicitly when needed")
@DisplayName("Generate activity image from test FIT file")
void testGenerateActivityImage_Manual() throws Exception {
// Load test FIT file