kubevela/pkg/policy
AshvinBambhaniya2003 d6ad578070
Feat(tests): Add unit test coverage for core packages (#6889)
* test(resourcekeeper): add unit tests for resource management

This commit introduces new unit tests to improve the test coverage of the `resourcekeeper` package.

- A new test file `containsresources_test.go` is added, which includes a comprehensive table-driven test for the `ContainsResources` function.
- A new table-driven test, `TestUpdateSharedManagedResourceOwner`, is added to `gc_test.go` to verify the logic for updating ownership of shared resources.

These tests follow Go best practices and enhance the robustness of the resourcekeeper functionality.

Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com>

* feat(resourcetracker): add unit tests for tree display logic

This commit enhances the test coverage for the resource tree display logic in the `pkg/resourcetracker` package.

- Refactors `TestResourceTreePrintOption_getWidthForDetails` to cover more cases and improve test clarity.
- Adds a comprehensive test for `TestPrintResourceTree` to verify the output of the resource tree printing.
- Introduces a new test for the `tableRoundTripper` to ensure the HTTP `Accept` header is correctly mutated.
- Adds tests for helper functions like `TestLoadResourceRows`, `TestSortRows`, and `TestFillResourceRows` to ensure each part of the tree building logic is working as expected.
These changes improve the overall quality and reliability of the resource tracker's tree view functionality.

Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com>

* feat(envbinding): add unit tests for placement logic

This commit enhances the test coverage for the `envbinding` policy package.

- Adds a new test for `WritePlacementDecisions` to verify the logic of writing placement decisions to the application status. This includes scenarios for adding new policies, updating existing ones, and handling malformed data.

Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com>

* feat(schema): add unit tests for schema parsing and conversion

This commit enhances the test coverage for the `pkg/schema` package by adding unit tests for CUE parsing and OpenAPI schema conversion.

- Adds a new test for `ParsePropertiesToSchema` to verify that CUE parameter definitions are correctly parsed into OpenAPI schemas.
- Introduces a new test for `ConvertOpenAPISchema2SwaggerObject` to ensure the conversion from a raw OpenAPI v3 schema to a Swagger object is handled correctly, including error cases.
These tests improve the reliability of the schema generation and conversion logic, which is critical for capability definitions.

Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com>

---------

Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com>
2025-09-11 07:29:07 +08:00
..
envbinding Feat(tests): Add unit test coverage for core packages (#6889) 2025-09-11 07:29:07 +08:00
utils
common.go
common_test.go
override.go
override_test.go
replication.go
replication_test.go
topology.go
topology_test.go Chore: upgrade Kubernetes dependencies to v0.31.10 & enhance CLI, workflows, tests, and documentation (#6837) 2025-07-31 07:46:56 -07:00