Skip to content

feat(redis): move examples and test into a separate Go module#3726

Open
ash2k wants to merge 1 commit into
testcontainers:mainfrom
ash2k:move-redis
Open

feat(redis): move examples and test into a separate Go module#3726
ash2k wants to merge 1 commit into
testcontainers:mainfrom
ash2k:move-redis

Conversation

@ash2k

@ash2k ash2k commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Move examples and test for the Redis module into a separate Go module.

Why is it important?

This avoids having github.com/redis/go-redis/v9 as a dependency. I use a different Redis client and would like to avoid an extra dependency. Even if its coming via tests, it still shows up in go.sum.

Related issues

This avoids having github.com/redis/go-redis/v9 as a dependency.
@ash2k ash2k requested a review from a team as a code owner June 15, 2026 13:13
@netlify

netlify Bot commented Jun 15, 2026

Copy link
Copy Markdown

Deploy Preview for testcontainers-go failed.

Name Link
🔨 Latest commit bed1297
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/6a2ffa80a79b9a0008c7fdc9

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9454d583-a25b-40b5-81a7-d7d236b9974c

📥 Commits

Reviewing files that changed from the base of the PR and between 96ab095 and bed1297.

⛔ Files ignored due to path filters (2)
  • modules/redis/example/go.sum is excluded by !**/*.sum
  • modules/redis/go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • modules/redis/example/examples_test.go
  • modules/redis/example/go.mod
  • modules/redis/example/redis_test.go
  • modules/redis/example/testdata/Dockerfile
  • modules/redis/example/testdata/redis6.conf
  • modules/redis/example/testdata/redis7.conf
  • modules/redis/go.mod

Summary by CodeRabbit

  • Chores
    • Updated Redis module test configuration and restructured module dependencies for improved test organization.

Walkthrough

The Redis example tests are extracted into a new standalone Go module (modules/redis/example) with its own go.mod, replace directives pointing to local paths, and pinned direct/indirect dependencies. Package declarations in both example test files are renamed from redis_test to example, and the parent modules/redis/go.mod drops the now-migrated direct dependencies.

Changes

Redis example module extraction

Layer / File(s) Summary
New example module: go.mod and package renames
modules/redis/example/go.mod, modules/redis/example/examples_test.go, modules/redis/example/redis_test.go
Adds go.mod declaring the github.com/testcontainers/testcontainers-go/modules/redis/example module with direct dependencies (google/uuid, go-redis/v9, stretchr/testify, testcontainers-go*), replace directives for local paths, and a full indirect dependency block. Renames both test files' package from redis_test to example.
Parent redis module dependency cleanup
modules/redis/go.mod
Removes google/uuid and go-redis/v9 from direct requirements, removes dgryski/go-rendezvous from indirect requirements, and re-adds google/uuid as an indirect dependency.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A module was nested, all tangled and tight,
So I hopped to the example and made it stand right.
A go.mod new bloomed in the redis/example tree,
With replace directives pointing back home to me.
The parent trimmed deps — less clutter, more cheer!
✨ Clean modules are music to every rabbit's ear.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: moving Redis examples and tests into a separate Go module.
Description check ✅ Passed The description clearly explains what the PR does, why it matters, and directly relates to the changeset of moving examples into a separate module.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mdelapenya

Copy link
Copy Markdown
Member

@ash2k I'd like to understand better the need for the separation, as the Go tool chain will strip any test dependency from the final binary you create, so no testcontainers-go dependency should land into the production binaries. Isn't that the case here?

@ash2k

ash2k commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@mdelapenya This is optional. I thought it's nicer to not have anything extra as a dependency. Also, I think (but not 100% sure) all of the modules (even test dependencies of dependencies) participate in version resolution. Not a problem for me though. Feel free to close this.

On the other hand, this repo did separate things into separate modules to cut down on dependency bloat, right? So this change basically follows the same idea.

@@ -1,4 +1,4 @@
package redis_test
package example

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change seems wrong to me, as we will be removing the tests from the redis module.

I'm happy to have the example package (better to name it v9?) but the tests must live in the module itself.

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.

2 participants