You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance approve command with visual diff and execution checks (#192)
This pull request enhances the `approve` command in the CLI by
introducing an interactive visual diff for pending secret mutations,
improving user experience and safety. It also significantly expands the
test suite for the `approve` command and refactors test utilities to
better isolate environment variables, ensuring more reliable and
maintainable tests.
**Approve command improvements:**
* The `approve` command now fetches pending secret mutations, displays a
visual diff of changes (additions, deletions, modifications), and
prompts the user for interactive approval. If not in an interactive
terminal, it aborts with an error. This improves clarity and prevents
accidental approvals.
* Added a helper function `isInteractive()` to reliably detect if the
terminal is interactive, supporting robust interactive prompts and test
overrides.
* Refactored diff logic by extracting `computeDiffFromMap`, allowing the
diff to be generated from an in-memory map, which simplifies both the
command logic and testing.
**Testing improvements:**
* Major expansion of tests for the `approve` command, covering
interactive approval, abort scenarios, non-interactive errors, and token
validation. Introduced helper functions for setting up mock servers,
home directories, and filtering environment variables for isolation.
* Added a dedicated test for `computeDiffFromMap` to ensure diff
calculation correctness.
**Test utility and environment management:**
* Introduced `filterEnv` and `filterEnvRoot` helper functions to
consistently exclude sensitive or test-specific environment variables
from test subprocesses, reducing flakiness and side effects across the
test suite. Updated all affected tests to use these helpers.
**Dependency and import updates:**
* Updated imports in `approve.go` and related files to include new
internal modules and Go standard libraries required for the new
functionality.
These changes together make the approval process safer and more
user-friendly, while also making the codebase easier to test and
maintain.
---
Co-authored-by: Rajat Patra <113469515+RawJat@users.noreply.github.com>
0 commit comments