Add H2 in-memory database to fix CI application context crash - #5
Merged
Conversation
fix(backend): add h2 in-memory database to resolve CI application con…
There was a problem hiding this comment.
Pull request overview
This PR updates the backend test/build setup so Spring Boot tests can start an application context with an in-memory database (H2), avoiding failures caused by missing external DB configuration in CI.
Changes:
- Added
com.h2database:h2as a test-scoped dependency inbackend/pom.xml. - Updated
BackendApplicationTeststo use the default@SpringBootTestconfiguration (no longer excludingDataSourceAutoConfiguration). - Minor
pom.xmlXML formatting/whitespace simplifications.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
backend/pom.xml |
Adds H2 (test scope) and applies minor XML formatting changes to support DB-backed test context initialization. |
backend/src/test/java/com/campushub/backend/BackendApplicationTests.java |
Enables default Spring Boot context loading so tests can exercise the H2-backed DataSource auto-configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request primarily makes improvements to the
backend/pom.xmlbuild configuration and updates the test setup for the backend application. The most significant update is the addition of the H2 in-memory database as a test dependency, which will make it easier to run tests without needing a real database connection. There are also several formatting changes to simplify the XML structure, and the test configuration is updated to use the default Spring Boot context.Dependency and test infrastructure improvements:
com.h2database:h2dependency withtestscope to enable in-memory database testing, making backend tests more reliable and independent of external resources.BackendApplicationTeststo use the default@SpringBootTestannotation, removing the exclusion ofDataSourceAutoConfiguration, which allows tests to use the H2 database included above.Build file formatting and simplification:
pom.xmlfor licenses, developers, SCM, and plugin goals to improve readability and maintainability. [1] [2] [3]