Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor][kubectl-plugin] simplify cobra Validate() tests #3040

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davidxia
Copy link
Contributor

We were duplicating logic in each command's Validate() test.

  1. Abstract away K8s context detection logic with a new interface KubeContexter.
  2. Consolidate tests for this logic in a separate test for DefaultKubeContexter.
  3. Mock KubeContexter in Validate() tests with MockKubeContexter to simplify the Validate() tests.

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

We were duplicating logic in each command's `Validate()` test.

1. Abstract away K8s context detection logic with a new interface `KubeContexter`.
1. Consolidate tests for this logic in a separate test for `DefaultKubeContexter`.
1. Mock `KubeContexter` in `Validate()` tests with `MockKubeContexter` to
   simplify the `Validate()` tests.

Signed-off-by: David Xia <david@davidxia.com>
@davidxia davidxia marked this pull request as ready for review February 13, 2025 15:52
@MortalHappiness MortalHappiness self-assigned this Feb 15, 2025
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