Skip to content

Test: add real database integration tests for EntityCreator#6378

Open
DharunMR wants to merge 1 commit intomindersec:mainfrom
DharunMR:integration-tests-with-real-db
Open

Test: add real database integration tests for EntityCreator#6378
DharunMR wants to merge 1 commit intomindersec:mainfrom
DharunMR:integration-tests-with-real-db

Conversation

@DharunMR
Copy link
Copy Markdown
Contributor

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.

@DharunMR DharunMR requested a review from a team as a code owner April 15, 2026 16:36
Signed-off-by: DharunMR <maddharun56@gmail.com>
@DharunMR DharunMR force-pushed the integration-tests-with-real-db branch from d186372 to 8f3d900 Compare April 15, 2026 17:13
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 59.712% (+0.2%) from 59.539% — DharunMR:integration-tests-with-real-db into mindersec:main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants