test(cli): add coverage for catalog validation edge cases#6413
test(cli): add coverage for catalog validation edge cases#6413sachin9058 wants to merge 11 commits into
Conversation
…quickstart from clone helper
… for quickstart Signed-off-by: Sachin Kumar <sachinkumar905846@gmail.com>
evankanderson
left a comment
There was a problem hiding this comment.
Just a few comments on the tests -- I think it's reasonable (and good!) to include the tests alongside the PR, so I would fold this into #6364 that it's built on.
That also makes it easier to check whether the overall coverage went up or down when reviewing the PR.
|
|
||
| func TestCatalogValidate_EmptyCatalog(t *testing.T) { | ||
| t.Parallel() | ||
| catalog := &Catalog{ |
There was a problem hiding this comment.
Since Catalog isn't implementing an interface, you don't need to take a reference here -- it's fine to build it on the stack.
| minderv1 "github.com/mindersec/minder/pkg/api/protobuf/go/minder/v1" | ||
| ) | ||
|
|
||
| func TestCatalogValidate_NilCatalog(t *testing.T) { |
There was a problem hiding this comment.
These feel like they would fit the Go data-driven test case pattern used in internal/util/cli/cli_test.go et al very well.
(Also, why introduce a new directory, rather than re-using internal/util/cli?)
|
@evankanderson Thanks for the feedback I’ve merged the test coverage into #6364 so implementation and tests are reviewed together. I’ve also:
For now I’ve kept the tests alongside the catalog logic in internal/cli, but I’m happy to move them to internal/util/cli if that’s preferred. Let me know if this looks better aligned. |
Summary
This PR adds test coverage for catalog validation logic, focusing on edge cases and behavior when handling invalid or incomplete data.
It is based on the catalog loading and validation changes introduced in #6364 and is part of a stacked PR sequence.
Motivation
The catalog loading flow introduces validation logic that filters invalid profiles and ensures rule type references are correct. Adding tests for these scenarios improves confidence in the behavior and prevents regressions in edge cases.
Changes
Added tests for
Catalog.Validatecovering:Nil catalog handling
Empty catalog
Valid catalog
Invalid rule references
Behavior Verified
Stacked PR Context
This PR depends on #6364, which introduces the catalog loading and validation logic.
To keep changes small and reviewable:
Once #6364 is merged, this PR will only contain the test changes.
Testing
All tests pass locally:
Notes
This PR intentionally focuses on behavior validation rather than implementation details, ensuring flexibility if the underlying logic evolves.