test: establish integration test suite using testcontainers (#67) - #70
Merged
Conversation
Add a separate integration/ Go module with black-box tests that boot the CLI and Docker image against a real environment. Kept as a nested module so testcontainers-go's Docker dependency tree stays out of the published library's go.mod. Tests added: - TestRun_BindError — Server.Run surfaces a bind error when the port is occupied - TestRun_GracefulShutdown — context cancellation shuts down cleanly within 10 s - TestServe_Smoke — Docker image starts and serves HTTP 200 - TestServe_LiveReload — watcher detects a file change and the server reflects it - TestServe_BlogRootFlag — -p flag correctly prefixes all generated links Also adds a dedicated CI job, a just test-integration recipe, and updates CONTRIBUTING.md to document the suite and its Docker prerequisite. Fixes #67
Addresses correctness and robustness issues surfaced by a high-effort code review of the integration test suite added in #67. - Distinguish Docker-unavailable from image-build failure: extract TestMain body into run() so defer cancel() fires before os.Exit, and probe Docker health separately before calling buildTestImage — a Dockerfile/compile failure now exits non-zero instead of silently skipping all container tests with a false-green result. - Add defer cancel() in TestRun_GracefulShutdown so the srv.Run goroutine is always unwound, even when eventually times out before the server becomes ready. - Fix eventually loop boundary: restructure to always call fn() once more after the deadline, preventing conditions that become true in the last sleep window from being silently missed. - Log io.ReadAll errors in httpGet so body-read failures surface in verbose output rather than producing opaque "condition not met" timeouts. - Document the TOCTOU port-race in TestRun_GracefulShutdown with a comment explaining why it is accepted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a separate integration/ Go module with black-box tests that boot the CLI and Docker image against a real environment. Kept as a nested module so testcontainers-go's Docker dependency tree stays out of the published library's go.mod.
Tests added:
Also adds a dedicated CI job, a just test-integration recipe, and updates CONTRIBUTING.md to document the suite and its Docker prerequisite.
Fixes #67
Changelog (#70)
🧪 Tests