mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
* test(cli): enhance unit test coverage for theme and color config This commit introduces a comprehensive suite of unit tests for the theme and color configuration functions in `references/cli/top/config`. Key changes include: - Refactored existing tests in `color_test.go` to use table-driven sub-tests for improved clarity and maintainability. - Added new test functions to validate color parsing, hex color detection, and default theme creation. - Implemented tests for theme file lifecycle management, including creation and loading logic. These additions significantly increase the test coverage and ensure the robustness and correctness of the CLI's theme and color functionality. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * test(cli): refactor and enhance tests for top view models and utils This commit improves the unit test suite for the CLI's top view functionality by refactoring existing tests and adding new ones to increase coverage. Key changes include: - In `application_test.go`, `TestApplicationList_ToTableBody` is refactored to be a table-driven test, and new tests are added for `serviceNum`, `workflowMode`, and `workflowStepNum` helpers. - In `time_test.go`, `TestTimeFormat` is refactored into a table-driven test for better structure and readability. These changes align the tests with best practices and improve the overall robustness of the CLI top view's data presentation logic. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * test(cuegen): enhance unit test coverage for CUE generation packages This commit introduces a comprehensive suite of unit tests and refactors existing tests for the CUE generation packages located in `references/cuegen`. Key changes include: - Refactored existing tests in `generator_test.go` and `provider_test.go` to use table-driven sub-tests, improving clarity, maintainability, and coverage of error conditions. - Added new test functions to `convert_test.go` to validate helper functions for comment generation, type support, and enum field handling. - Added new tests in `provider_test.go` to cover provider extraction, declaration modification, and panic recovery logic. These changes significantly increase the test coverage for the `cuegen` libraries, ensuring the correctness and robustness of the CUE code generation functionality. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * test(docgen): add comprehensive unit tests for doc generation This commit introduces a comprehensive suite of unit tests for the documentation generation package located in `references/docgen`. Key changes include: - Added new test files (`console_test.go`, `convert_test.go`, `openapi_test.go`) to cover the core functions for parsing and generating documentation for CUE, Terraform, and OpenAPI schemas. - Refactored and enhanced `i18n_test.go` to use sub-tests, resolve race conditions, and improve coverage for fallback logic and error handling. - Ensured all new and existing tests follow best practices, using table-driven tests for clarity and maintainability. This effort significantly increases the test coverage for the `docgen` package, improving the reliability and robustness of the documentation generation features. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * test: improve test reliability and conventions This commit introduces several improvements to the test suite to enhance reliability and adhere to best practices. - **Fix flaky test in `docgen/openapi_test.go`**: The test for `GenerateConsoleDocument` was flaky because it performed an exact string match on table output generated from a map. Since map iteration order is not guaranteed, this could cause spurious failures. The test is now order-insensitive, comparing sorted sets of lines instead. - **Improve assertions in `docgen/console_test.go`**: - Removes an unnecessary `test.EquateErrors()` option, which is not needed for simple string comparisons. - Corrects the `cmp.Diff` argument order to the standard `(want, got)` convention for clearer failure messages. - Fixes a typo in an error message. - **Standardize assertions in `cli/top/config/color_test.go`**: Swaps `assert.Equal` arguments to the standard `(expected, actual)` convention. - **Clean up `cuegen/generators/provider/provider_test.go`**: Removes a redundant error check. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> --------- Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com>