Skip to content

test: establish integration test suite using testcontainers (#67) - #70

Merged
harrydayexe merged 2 commits into
mainfrom
integration-tests
Jun 12, 2026
Merged

test: establish integration test suite using testcontainers (#67)#70
harrydayexe merged 2 commits into
mainfrom
integration-tests

Conversation

@harrydayexe

@harrydayexe harrydayexe commented Jun 12, 2026

Copy link
Copy Markdown
Owner

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

Changelog (#70)

🧪 Tests

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.
@harrydayexe
harrydayexe merged commit 1e2f101 into main Jun 12, 2026
5 checks passed
@harrydayexe
harrydayexe deleted the integration-tests branch June 12, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: establish integration test suite using testcontainers

1 participant