Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoDB example #723

Merged
merged 3 commits into from
Jan 4, 2023
Merged

Conversation

ravilushqa
Copy link
Contributor

What does this PR do?

Added example for MongoDB

Why is it important?

MongoDB doesn't have example yet

Related issues

@ravilushqa ravilushqa requested a review from a team as a code owner January 4, 2023 16:58
@netlify
Copy link

netlify bot commented Jan 4, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 7a72ec2
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/63b5b03447f1aa0008fa2421
😎 Deploy Preview https://deploy-preview-723--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@@ -1,4 +1,4 @@
name: Mongodb example pipeline
name: MongoDB example pipeline
Copy link
Member

Choose a reason for hiding this comment

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

This is a good point, as the generator does not distinguish this notation including initials. I'll take a note to include a way to provide a variant that overrides the titled names

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, anyway, great work on the generator. It saves a lot of time 💪

@mdelapenya mdelapenya added the documentation Docs, docs, docs. label Jan 4, 2023
@mdelapenya mdelapenya self-assigned this Jan 4, 2023
}

// setupMongoDB creates an instance of the mongodb container type
func setupMongoDB(ctx context.Context) (*mongodbContainer, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Were you able to take a look at the Java implementation, or do you think this simple example is enough?

Copy link
Member

Choose a reason for hiding this comment

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

In any case, this LGTM. I'll merge it as is and we can iterate and evolve the example in follow ups, if you are interested

Copy link
Contributor Author

@ravilushqa ravilushqa Jan 4, 2023

Choose a reason for hiding this comment

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

I have a look into Java implementation, looks like it's supports replica set that looks like for me as an option. I doesn't need it, and I believe if someone will need it, it could be added as an option, as container option.
From my perspective it is good enough, as it just works and doesn't require overcomplicating it at this stage.

If we will add these rows below test, it will work, and this is most common usecase for tests, just perform operations

res, err := mongoClient.Database("test").Collection("test").InsertOne(ctx, bson.M{"test": "test"})
if err != nil {
	t.Fatal(fmt.Errorf("error inserting document into mongo: %w", err))
}

if res.InsertedID == nil {
	t.Fatal("expected InsertedID to not be nil")
}

wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me 👏

Copy link
Member

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

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

Thanks for your time adding this example! Much appreciated :)

@mdelapenya mdelapenya merged commit bf96707 into testcontainers:main Jan 4, 2023
@ravilushqa
Copy link
Contributor Author

thank you for maintaining this great project and rapid review ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Docs, docs, docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants