mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
* feat(monitor): Add unit tests for application metrics watcher This commit introduces a new test file with comprehensive unit tests for the application metrics watcher functionality in pkg/monitor/watcher. Key additions include: - Test cases for the application metrics watcher's inc() method covering add, delete, and update operations - Test cases for report() method that verifies dirty flags are cleared - Test cases for helper functions getPhase() and getApp() These additions improve the overall test coverage and ensure the correctness of the application metrics monitoring functionality. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat(velaql): Add comprehensive unit tests for ParseVelaQLFromPath This commit introduces new unit tests for the ParseVelaQLFromPath function in pkg/velaql, along with test data files to improve test coverage and ensure correctness. Key additions include: - `pkg/velaql/parse_test.go`: Adds TestParseVelaQLFromPath function with comprehensive test cases covering: * Valid CUE files with and without export fields * Nonexistent and empty file paths * Invalid CUE content * Files with invalid export types - Test data files in pkg/velaql/testdata/: * simple-valid.cue: Valid CUE file with export field * simple-no-export.cue: Valid CUE file without export field * empty.cue: Empty CUE file * invalid-cue-content.cue: CUE file with invalid syntax * invalid-export.cue: CUE file with invalid export type These additions improve the overall test coverage and ensure the robustness of the VELAQL parsing functionality. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat(webhook): Add unit tests for ValidateDefinitionRevision function This commit introduces new unit tests for the ValidateDefinitionRevision function in pkg/webhook/utils to improve test coverage and ensure correctness of definition revision validation. Key additions include: - `pkg/webhook/utils/utils_test.go`: Adds TestValidateDefinitionRevision function with comprehensive test cases covering: * Success scenarios with matching definition revisions * Success scenarios when definition revision does not exist * Failure scenarios with revision hash mismatches * Failure scenarios with spec mismatches * Failure scenarios with invalid definition revision names These additions improve the overall test coverage and ensure the robustness of the webhook utility functions for validating definition revisions. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat(workflow): Add unit tests for OAM apply and query utilities This commit introduces new unit tests for workflow provider functions in pkg/workflow/providers to improve test coverage and ensure correctness. Key additions include: - `pkg/workflow/providers/oam/apply_test.go`: Adds TestRenderComponent function with comprehensive test cases for component rendering - `pkg/workflow/providers/query/utils_test.go`: Adds: * TestBuildResourceArray function with comprehensive test cases covering simple, nested, and complex resource tree scenarios * TestBuildResourceItem function with test cases for resources with and without annotations These additions improve the overall test coverage and ensure the robustness of the workflow provider functions for OAM applications. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * fix(velaql): Improve error handling in ParseVelaQLFromPath test This commit addresses an issue in the TestParseVelaQLFromPath function where file read errors were being silently ignored. The changes include: - Removing the unused expectedView field from test cases - Replacing conditional error checking with require.NoError to ensure file read operations are properly validated - Ensuring that test failures are properly reported when file reading fails This fix improves the reliability of the test suite by making sure that any file I/O errors are properly caught and reported rather than silently ignored. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat: Apply cross-cutting test improvements Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat: Enhance test coverage with file-specific suggestions This commit applies file-specific suggestions to enhance the test suite's coverage and robustness. Key changes include: - **`pkg/monitor/watcher/application_test.go`**: - Added a test case for a multi-step workflow with mixed phases to validate `stepPhaseCounter` aggregation. - Added a test for idempotence by calling `inc` twice. - Added test cases for an empty workflow and an unknown application phase. - Strengthened the `report` test to assert that counters are not cleared. - **`pkg/velaql/parse_test.go`**: - Added a test case for `ParseVelaQLFromPath` to handle files with leading/trailing whitespace. - Added a test case to ensure consistent error messages for relative paths. - **`pkg/webhook/utils/utils_test.go`**: - Added a test case to `TestValidateCueTemplate` for a malformed CUE template. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> --------- Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com>
5 lines
64 B
CUE
5 lines
64 B
CUE
invalid cue syntax [
|
|
missing: colon
|
|
invalid: brackets
|
|
}
|