test: add tests for KORTEX_CLI_STORAGE support#26
Conversation
Signed-off-by: Philippe Martin <phmartin@redhat.com>
📝 WalkthroughWalkthroughThis PR adds documentation updates to AGENTS.md clarifying testing practices with environment variables and parallel tests, and introduces a new test suite TestRootCmd_StorageEnvVariable in pkg/cmd/root_test.go that validates environment variable and flag override behavior for the storage configuration. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/cmd/root_test.go (1)
211-213: Minor: Comment could be more precise.The comment says "unset the environment variable" but
t.Setenv("KORTEX_CLI_STORAGE", "")sets it to an empty string rather than truly unsetting it. This works correctly here becauseNewRootCmd()checksenvStorage != "", but the distinction could matter in other contexts.📝 Suggested comment clarification
t.Run("default used when env var not set", func(t *testing.T) { - // Explicitly unset the environment variable (in case it was set in the shell) + // Set the environment variable to empty string to simulate it not being set t.Setenv("KORTEX_CLI_STORAGE", "")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/cmd/root_test.go` around lines 211 - 213, The comment in the test around t.Setenv("KORTEX_CLI_STORAGE", "") is imprecise: t.Setenv sets the variable to an empty string rather than unsetting it. Update the comment to state that the env var is being set to an empty string (or, if you intend to truly unset it, replace t.Setenv with a call that unsets the variable such as os.Unsetenv or t.Setenv(..., "") paired with removing the key in the environment) and ensure the test behavior around NewRootCmd() (which checks envStorage != "") is clearly referenced.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/cmd/root_test.go`:
- Around line 211-213: The comment in the test around
t.Setenv("KORTEX_CLI_STORAGE", "") is imprecise: t.Setenv sets the variable to
an empty string rather than unsetting it. Update the comment to state that the
env var is being set to an empty string (or, if you intend to truly unset it,
replace t.Setenv with a call that unsets the variable such as os.Unsetenv or
t.Setenv(..., "") paired with removing the key in the environment) and ensure
the test behavior around NewRootCmd() (which checks envStorage != "") is clearly
referenced.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b82789eb-2f7d-41da-a8c2-03dcf24d4be5
📒 Files selected for processing (2)
AGENTS.mdpkg/cmd/root_test.go
No description provided.