Test: add real database integration tests for EntityCreator#6378
Open
DharunMR wants to merge 1 commit intomindersec:mainfrom
Open
Test: add real database integration tests for EntityCreator#6378DharunMR wants to merge 1 commit intomindersec:mainfrom
DharunMR wants to merge 1 commit intomindersec:mainfrom
Conversation
Signed-off-by: DharunMR <maddharun56@gmail.com>
d186372 to
8f3d900
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR add real database integration tests for the entity creation service (internal/entities/service/entity_creator.go).
Previously, the entity creation logic was heavily reliant on unit tests with a mock store. By utilizing Minder's embedded PostgreSQL engine, this PR introduces a robust integration suite that verifies the service's behavior against strict relational database constraints while mocking external network/API calls via gomock.
Specifically, this adds coverage for:
The Happy Path (TestEntityCreator_Integration_HappyPath): Verifies the full flow from provider property fetching, name resolution and provider registration down to SQL transaction persistence and property JSON serialization.
Parent/Child Relational Linking (TestEntityCreator_Integration_WithOriginator): Validates that providing an OriginatingEntityID correctly maps to the originated_from foreign key column in Postgres (e.g., linking Artifacts to Repositories).
Transaction Rollbacks & Cleanup (TestEntityCreator_Integration_RollbackCleanup): A "sad path" test that intentionally sabotages the database transaction to prove that CreateEntity safely rolls back and successfully triggers the cleanupProviderRegistration (DeregisterEntity) deferral to prevent orphaned webhooks on the provider.