Skip to content

Add integration test#16

Merged
bmcdonald3 merged 1 commit into
mainfrom
add-testing
Mar 25, 2026
Merged

Add integration test#16
bmcdonald3 merged 1 commit into
mainfrom
add-testing

Conversation

@bmcdonald3
Copy link
Copy Markdown
Member

Summary

This PR introduces a new integration test for the DiscoverySnapshot API to verify the end-to-end flow from HTTP POST to database persistence. The test utilizes an in-memory Ent SQLite driver to ensure a clean, isolated environment without side effects on local storage.

Changes

New Test File: Created cmd/server/integration_test.go.

Logic Verified:

  • Initialization of an in-memory SQLite database using enttest.
  • Registration of required resource prefixes for the fabrica naming schema.
  • Simulation of a POST /discoverysnapshots request with a complex hardware payload (Node, CPU, and DIMM).
  • Verification of the 201 Created response and JSON body consistency.
  • Verification that the record was correctly written to the storage layer via storage.LoadDiscoverySnapshot.
$ go test -v cmd/server/integration_test.go cmd/server/device_handlers_generated.go cmd/server/discoverysnapshot_handlers_generated.go cmd/se
rver/export.go cmd/server/import.go cmd/server/main.go cmd/server/models_generated.go cmd/server/openapi_generated.go cmd/server/routes_gener
ated.go
=== RUN   TestDiscoverySnapshotIntegration
--- PASS: TestDiscoverySnapshotIntegration (0.01s)
PASS
ok      command-line-arguments  1.954s

Signed-off-by: Ben McDonald <ben.mcdonald@hpe.com>
@bmcdonald3 bmcdonald3 merged commit cef981b into main Mar 25, 2026
1 check passed
@bmcdonald3 bmcdonald3 deleted the add-testing branch March 25, 2026 18:47
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.

1 participant