Skip to content

Conversation

@sanjana2505006
Copy link

Fixed an issue where the grails-testing-support-mongodbdependency wasn't included when generating projects with MongoDB and TestContainers. Also added a new guide to the docs explaining how to unit test with MongoDB.

Fixes #15007

Copy link
Contributor

@jdaugherty jdaugherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanjana2505006 please test changes locally before opening PRs

[source,groovy,subs="attributes"]
testCompile "org.apache.grails:grails-testing-support-datamapping"
testCompile "org.apache.grails:grails-testing-support-web"
testCompile "org.apache.grails:grails-testing-support-mongodb"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be a default recommendation. Not everyone uses mongodb. I also dont' think this is the right scope since the class will be needed at runtime of the test as well as compile.

@@ -0,0 +1,34 @@
# Unit Testing GORM for MongoDB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library is not just for unit testing. it's for integration testing as well.

String driver = "org.testcontainers.jdbc.ContainerDatabaseDriver";
if (driverFeature instanceof SQLServer) {
generatorContext.addTemplate("sqlserverEula", new StringTemplate("src/test/resources/container-license-acceptance.txt", "mcr.microsoft.com/mssql/server:2019-CU4-ubuntu-16.04"));
generatorContext.addTemplate("sqlserverEula",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not reformat these files unless it's across different commits.

|| generatorContext.isFeaturePresent(MongoGorm.class)) {
generatorContext.addDependency(Dependency.builder()
.groupId("org.apache.grails")
.artifactId("grails-testing-support-mongodb")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the wrong group id

@sanjana2505006
Copy link
Author

@jdaugherty Thank you for the detailed feedback! I have updated the PR to address all the points:
I created a dedicated MongoDBTestContainers feature in Forge properly this time instead of modifying the main TestContainers class and fixed the group ID to org.apache.grails.testing. I also reverted the formatting changes and the default installation guide change.

For the docs, I added a specific page for pure MongoDB testing (covering both unit/integration) as requested.

Verified everything locally by running the Forge tests and building the docs. It's all squashed into one clean commit now. Let me know if it looks good!

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Explore MongoDB Testing Feature for Forge

2 participants