mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
* feat(addon): add comprehensive unit tests for addon readers This commit enhances the test coverage and code quality for the addon reader implementations in the pkg/addon package. - Refactors all existing addon reader tests (gitee, github, gitlab, local) to use consistent, modern testing patterns like sub-tests. - Replaces the old memory_reader_test.go with a completely refactored implementation. - Adds new unit tests for previously untested functions, including various getters, client constructors, and RelativePath helpers. - Improves http-based tests (gitlab, github, gitee) to use robust mock handlers that correctly simulate API behavior, including pagination and error states. These changes improve the overall quality and reliability of the addon system and uncovered two minor bugs during the process. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat(addon): add more unit tests for addon helpers This commit continues to improve the test coverage for the pkg/addon package by adding unit tests for several helper and factory functions. - Adds a test for WrapErrRateLimit to ensure GitHub API rate limit errors are handled correctly. - Adds a test for ClassifyItemByPattern to verify addon file classification logic. - Adds a test for the NewAsyncReader factory function to ensure correct reader instantiation. - Adds tests for various utility functions in utils.go, including IsRegistryFuncs, InstallOptions, ProduceDefConflictError, and GenerateChartMetadata. These tests increase the reliability of the addon installation and handling logic. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * feat(addon): add unit tests for versioned addon registry This commit improves test coverage for the versioned addon registry logic in the pkg/addon package. - Adds a unit test for resolveAddonListFromIndex to verify the logic for parsing Helm index files. - Introduces a new table-driven test for the internal loadAddon function, covering success and multiple failure scenarios (e.g., version not found, download failure, corrupt data). - Adds a new test helper, setupAddonTestServer, to create isolated mock HTTP servers for testing addon loading, improving test reliability and clarity. These tests ensure the core logic for discovering and fetching versioned addons is robust and functions as expected. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * chore(addon): remove unused gitlab testdata path constant - remove unused gitlab testdata path constant name `gitlabTestdataPath` Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> * refactor(addon): improve unit tests based on review feedback This commit addresses several code review comments to improve the quality, correctness, and robustness of the unit tests in the pkg/addon package. - Refactors map key assertions in the memory reader test to use the correct "comma ok" idiom instead of assert.NotNil. - Updates the GitHub reader test to use a compliant addon mock that includes the required template.cue file. - Modifies the chart metadata test in utils_test.go to use t.TempDir() for better test isolation and automatic cleanup. - Switches from assert.NotNil to require.NotNil in the versioned registry test to prevent panics on nil pointers. These changes make the test suite more robust, reliable, and easier to maintain. Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com> --------- Signed-off-by: Ashvin Bambhaniya <ashvin.bambhaniya@improwised.com>
2.9 KiB
2.9 KiB