test: add comprehensive tests for Index functionality #86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Comprehensive Tests for Index Functionality
This PR adds comprehensive test coverage for the Index functionality in the ctipackage. The changes include:
Added Tests
Test_ReadIndex
: Tests reading an index from a directory pathTest_DecodeIndex
: Tests JSON decoding with both valid and invalid JSON inputTest_GenerateIndexRaml
: Tests RAML generation with and without examplesTest_Clone
: Tests deep copying functionalityTest_ToBytes
: Tests JSON marshalingTest_Save
: Tests saving index to fileTest_PutSerialized
: Tests adding serialized filesTest_GetEntities
: Tests entity retrievalTest_GetAssets
: Tests asset retrievalTest Coverage
All new tests are passing successfully. The tests cover both success and error cases, ensuring robust validation of the Index functionality.
Testing
Run the tests with:
go test ./metadata/ctipackage -v
Note: There are two unrelated failing tests in the codebase:
Test_ParseAnnotations/annotations
- Failing due to missing golden fileTest_InvalidPackage/missing_file
- Failing due to error message mismatchThese failures are in existing tests and not related to our new test additions.