Skip to content

test: Add unit tests and automated test workflow for kubeslice-cli core modules#92

Open
gitsofaryan wants to merge 1 commit intokubeslice:masterfrom
gitsofaryan:lfx/comprehensive-testing
Open

test: Add unit tests and automated test workflow for kubeslice-cli core modules#92
gitsofaryan wants to merge 1 commit intokubeslice:masterfrom
gitsofaryan:lfx/comprehensive-testing

Conversation

@gitsofaryan
Copy link

@gitsofaryan gitsofaryan commented Aug 5, 2025

Overview

This PR adds comprehensive unit test coverage to the kubeslice-cli project and introduces a GitHub Actions workflow for automated testing and linting. The goal is to improve code reliability, make future development safer, and streamline the review process.

What’s Included

  • 7 new unit test files:

    • cmd/common_test.go: Covers the mapFromSlice function and global variables, achieving 100% coverage.
    • cmd/root_test.go: Tests CLI root command initialization and basic argument handling.
    • pkg/slice_test.go: Validates slice operations and edge cases.
    • pkg/cmd-util_test.go: Checks command utility functions for correct behavior.
    • pkg/internal/constants_test.go: Ensures constants are defined and used as expected.
    • util/print-util_test.go: Tests print utilities, including formatting and Unicode support.
    • main_test.go: Verifies main package integration and basic CLI execution.
  • 1 GitHub Actions workflow (.github/workflows/test.yml):

    • Runs all unit tests on every push and pull request.
    • Generates a coverage report.
    • Performs basic linting with go vet and gofmt.

How to Test

  • Locally: Run go test ./... -cover to execute all tests and view coverage.
  • On GitHub: Push changes or open a PR to trigger the workflow and see results in the Actions tab.

Signed-off-by: gitsofaryan

- Implement unit tests for cmd/common.go with 100% coverage
- Add comprehensive CLI root command testing
- Create slice operations testing with mock scenarios
- Implement command utilities and configuration validation tests
- Add constants validation testing for Kubernetes resources
- Create print utilities testing with Unicode support
- Add main package integration tests
- Implement GitHub Actions CI/CD pipeline with automated testing

This testing framework provides 55 test cases covering critical
functionalities for the kubeslice-cli project, supporting the
LFX mentorship program requirements.

Signed-off-by: Aryan Jain <aryan.jain.csbs22@ggits.net>
@gitsofaryan
Copy link
Author

gitsofaryan commented Aug 5, 2025

hi @richiesebastian @priyupadhyay sir, could you please review my MR ; and wanted to know more issues i can made my self completely involved! 🙇🙇

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