Skip to content

Conversation

tcheeric
Copy link
Owner

Summary

  • run API integration tests using a nostr-rs-relay Testcontainer
  • use dynamic relay URI during tests
  • depend on Testcontainers
  • document Docker requirement for integration tests
  • make relay container image configurable via relay-container.properties

Testing

  • mvn -q verify (fails: Could not find a valid Docker environment)

https://chatgpt.com/codex/tasks/task_b_688a9b0841408331ad01ccb463386a41

Copilot

This comment was marked as outdated.

@tcheeric tcheeric requested a review from Copilot July 30, 2025 23:03
Copilot

This comment was marked as outdated.

@tcheeric tcheeric requested a review from Copilot July 30, 2025 23:39
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Modernizes integration tests by replacing hardcoded relay dependencies with Testcontainers, enabling automated Docker-based test environments. This improves test reliability and removes the need for manual relay setup.

  • Replaced hardcoded relay URIs with dynamic Testcontainers-managed relay instances
  • Added Testcontainers dependency and configuration for nostr-rs-relay Docker image
  • Updated documentation to reflect Docker requirement instead of manual relay setup

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pom.xml Added Testcontainers dependency version property
nostr-java-api/pom.xml Added Testcontainers JUnit Jupiter dependency
nostr-java-api/src/test/resources/relay-container.properties Configured default relay container image
nostr-java-api/src/test/java/nostr/api/integration/BaseRelayIntegrationTest.java Implemented Testcontainers infrastructure with dynamic relay URI generation
nostr-java-api/src/test/java/nostr/api/unit/NIP99ImplTest.java Fixed test assertion to avoid object equality issues
Multiple integration test files Replaced hardcoded relay URIs with dynamic relay URI method calls
README.md Updated documentation to reflect Docker requirement for integration tests

Comment on lines 40 to 45
relayUri = String.format("ws://localhost:%d", RELAY.getMappedPort(RELAY_PORT));
}

@DynamicPropertySource
static void registerRelayProperties(DynamicPropertyRegistry registry) {
relayUri = String.format("ws://localhost:%d", RELAY.getMappedPort(RELAY_PORT));
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relayUri is being set in both ensureDockerAvailable() and registerRelayProperties() methods. This creates a race condition where the value might be overwritten, and the container might not be started when getMappedPort() is called in ensureDockerAvailable().

Suggested change
relayUri = String.format("ws://localhost:%d", RELAY.getMappedPort(RELAY_PORT));
}
@DynamicPropertySource
static void registerRelayProperties(DynamicPropertyRegistry registry) {
relayUri = String.format("ws://localhost:%d", RELAY.getMappedPort(RELAY_PORT));
}
@DynamicPropertySource
static void registerRelayProperties(DynamicPropertyRegistry registry) {

Copilot uses AI. Check for mistakes.


@DynamicPropertySource
static void registerRelayProperties(DynamicPropertyRegistry registry) {
relayUri = String.format("ws://localhost:%d", RELAY.getMappedPort(RELAY_PORT));
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate assignment of relayUri. The @DynamicPropertySource method should not reassign the static field as it may be called multiple times and creates inconsistency with the @BeforeAll method.

Suggested change
relayUri = String.format("ws://localhost:%d", RELAY.getMappedPort(RELAY_PORT));

Copilot uses AI. Check for mistakes.

Comment on lines +5 to +6
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Spring Framework imports are being used in a class that doesn't appear to be a Spring test. Consider using pure Testcontainers approach without Spring dependencies if Spring context is not required.

Suggested change
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;

Copilot uses AI. Check for mistakes.

@tcheeric tcheeric merged commit eb7cfe9 into develop Jul 31, 2025
@tcheeric tcheeric deleted the codex/use-testcontainers-for-integration-tests branch July 31, 2025 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant