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

View file

@ -98,6 +98,10 @@ public class ActivityFormatter {
* *
*/ */
private static LocalDateTime getUtcDateTimeInZone(LocalDateTime utcDateTime, String timezone) { private static LocalDateTime getUtcDateTimeInZone(LocalDateTime utcDateTime, String timezone) {
if (timezone == null || timezone.isBlank()) {
return utcDateTime;
}
try { try {
return utcDateTime.atZone(ZoneOffset.UTC) return utcDateTime.atZone(ZoneOffset.UTC)
.withZoneSameInstant(ZoneId.of(timezone)) .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.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
import org.testcontainers.utility.DockerImageName; import org.testcontainers.utility.DockerImageName;
/** /**
@ -23,8 +22,6 @@ public class TestcontainersConfiguration {
) )
.withDatabaseName("testdb") .withDatabaseName("testdb")
.withUsername("test") .withUsername("test")
.withPassword("test") .withPassword("test");
.waitingFor(new HostPortWaitStrategy())
.withReuse(true);
} }
} }

View file

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