Skip to content

test(message/s3): unit + Garage integration tests for S3 adapter (#531) - #535

Open
Anthony-Bible wants to merge 1 commit into
masterfrom
test/531-s3-adapter-tests
Open

test(message/s3): unit + Garage integration tests for S3 adapter (#531)#535
Anthony-Bible wants to merge 1 commit into
masterfrom
test/531-s3-adapter-tests

Conversation

@Anthony-Bible

Copy link
Copy Markdown
Owner

Summary

  • Seam refactor (object_storage.go): introduce unexported interfaces multipartCore, objectGetter, and readerStat so *minio.Core / *minio.Client can be swapped with fakes in tests. NewS3Adapter signature and all method behaviours are unchanged; forms.go untouched.
  • 14 unit tests (object_storage_test.go): function-field fakes + testify/require/assert, covering every public method — happy paths, error propagation, contracts.CompletedPartminio.CompletePart ordering, and the close-on-Stat-error invariant for GetObject.
  • Garage integration helper (internal/integration/garagetest/garage.go, integration build tag): spins up dxflrs/garage:v1.0.1 via testcontainers generic container, provisions bucket + key, tears down via t.Cleanup. Image defaults to docker.io/dxflrs/garage:v1.0.1 (not on mirror.gcr.io — noted in comment) with PASSWORDEXCHANGE_TEST_GARAGE_IMAGE override.
  • 4 blackbox integration tests (object_storage_integration_test.go): multipart round-trip (5 MiB min-part + 1 KiB final, SHA-256 verified), abort discards upload, missing-key error, and bad-ETag rejection on complete.

Note on scope: the issue mentioned DeleteObject, but neither ObjectStoragePort nor S3Adapter defines that method — the issue text is stale. Tests cover the 5 real methods only.

Test plan

  • cd app && go test ./internal/domains/message/adapters/secondary/s3/... -v — 14 unit tests pass
  • cd app && go test -tags=integration ./internal/domains/message/adapters/secondary/s3/... -v — 4 Garage integration tests pass (requires Docker)
  • cd app && go test ./... — full unit suite still green
  • ./test-build.sh — build verification passes

🤖 Generated with Claude Code

Seam refactor (object_storage.go): introduce unexported interfaces
multipartCore, objectGetter, and readerStat so *minio.Core/*minio.Client
can be replaced with function-field fakes in tests. NewS3Adapter signature
and all method behaviours are unchanged; forms.go untouched.

14 unit tests (object_storage_test.go): cover every public method —
happy paths, error propagation, contracts.CompletedPart→minio.CompletePart
ordering, and the close-on-Stat-error invariant for GetObject.

Garage integration helper (internal/integration/garagetest/garage.go,
integration build tag): spins up dxflrs/garage:v1.0.1 via testcontainers
generic container and provisions a bucket + access key. Exposes both
StartGarage(t) for per-test use and MustStart() for TestMain. Image
defaults to docker.io/dxflrs/garage:v1.0.1 (not on mirror.gcr.io — noted
in comment) with PASSWORDEXCHANGE_TEST_GARAGE_IMAGE override.

4 blackbox integration tests share one container via TestMain: multipart
round-trip (5 MiB min-part + 1 KiB final, SHA-256 verified), abort
discards upload, missing-key error, and bad-ETag rejection on complete.

Note: the issue mentioned DeleteObject but neither ObjectStoragePort nor
S3Adapter defines that method — the issue text is stale. Tests cover the
5 real methods only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Anthony-Bible
Anthony-Bible force-pushed the test/531-s3-adapter-tests branch from 1a17ee5 to 5f72400 Compare June 5, 2026 13:42
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.

1 participant