-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
MongoDB example #723
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Mongodb example pipeline | ||
name: MongoDB example pipeline | ||
|
||
on: [push, pull_request] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# Mongodb | ||
# MongoDB | ||
|
||
<!--codeinclude--> | ||
[Creating a Mongodb container](../../examples/mongodb/mongodb.go) | ||
[Creating a MongoDB container](../../examples/mongodb/mongodb.go) | ||
<!--/codeinclude--> | ||
|
||
<!--codeinclude--> | ||
[Test for a Mongodb container](../../examples/mongodb/mongodb_test.go) | ||
[Test for a MongoDB container](../../examples/mongodb/mongodb_test.go) | ||
<!--/codeinclude--> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,8 @@ type mongodbContainer struct { | |
testcontainers.Container | ||
} | ||
|
||
// setupMongodb creates an instance of the mongodb container type | ||
func setupMongodb(ctx context.Context) (*mongodbContainer, error) { | ||
// setupMongoDB creates an instance of the mongodb container type | ||
func setupMongoDB(ctx context.Context) (*mongodbContainer, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me 👏 |
||
req := testcontainers.ContainerRequest{ | ||
Image: "mongo:6", | ||
ExposedPorts: []string{"27017/tcp"}, | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 💪