Skip to content

chore: add integration tests for insert-many #85

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

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

nirinchev
Copy link
Collaborator

Also, removes insertOne as it seems the model is good enough to figure out the usage of insert-many even with a single doc.

@nirinchev nirinchev requested a review from Copilot April 17, 2025 09:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

expect(content).toContain('Inserted `1` document(s) into collection "coll1"');
});

it("throw an error if connection string is not configured", async () => {
Copy link
Preview

Copilot AI Apr 17, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider updating the test description to 'throws an error if connection string is not configured' to maintain grammatical consistency.

Suggested change
it("throw an error if connection string is not configured", async () => {
it("throws an error if connection string is not configured", async () => {

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Comment on lines +73 to +77
await integration.connectMcpClient();
const response = await integration.mcpClient().callTool({
name: "insert-many",
arguments: {
database: integration.randomDbName(),
Copy link
Preview

Copilot AI Apr 17, 2025

Choose a reason for hiding this comment

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

Store the random database name in a variable and reuse it for both the tool call and the subsequent validation to ensure consistency between the created and verified namespaces.

Suggested change
await integration.connectMcpClient();
const response = await integration.mcpClient().callTool({
name: "insert-many",
arguments: {
database: integration.randomDbName(),
const dbName = integration.randomDbName();
await integration.connectMcpClient();
const response = await integration.mcpClient().callTool({
name: "insert-many",
arguments: {
database: dbName,

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

@coveralls
Copy link
Collaborator

coveralls commented Apr 17, 2025

Pull Request Test Coverage Report for Build 14591816093

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 51.628%

Totals Coverage Status
Change from base Build 14591775714: 0.08%
Covered Lines: 401
Relevant Lines: 681

💛 - Coveralls

@nirinchev nirinchev requested review from fmenezes and blva April 17, 2025 10:12
@@ -27,7 +27,7 @@ export class InsertManyTool extends MongoDBToolBase {
return {
content: [
{
text: `Inserted \`${result.insertedCount}\` documents into collection \`${collection}\``,
text: `Inserted \`${result.insertedCount}\` document(s) into collection "${collection}"`,
Copy link
Collaborator

@gagik gagik Apr 22, 2025

Choose a reason for hiding this comment

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

is there a reason for the change of the `?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mostly consistency - it doesn't really matter as in my experience, the model will not return the result as-is, but rather reformat it. But we've been using quotes in other places, so figured I should standardize around it.

Comment on lines +32 to +39
const args = [
{},
{ collection: "bar", database: 123, documents: [] },
{ collection: [], database: "test", documents: [] },
{ collection: "bar", database: "test", documents: "my-document" },
{ collection: "bar", database: "test", documents: { name: "Peter" } },
];
for (const arg of args) {
Copy link
Collaborator

@gagik gagik Apr 22, 2025

Choose a reason for hiding this comment

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

Suggested change
const args = [
{},
{ collection: "bar", database: 123, documents: [] },
{ collection: [], database: "test", documents: [] },
{ collection: "bar", database: "test", documents: "my-document" },
{ collection: "bar", database: "test", documents: { name: "Peter" } },
];
for (const arg of args) {
for (const arg of [
{},
{ collection: "bar", database: 123, documents: [] },
{ collection: [], database: "test", documents: [] },
{ collection: "bar", database: "test", documents: "my-document" },
{ collection: "bar", database: "test", documents: { name: "Peter" } },
]) {

Base automatically changed from ni/integration-create-index to main April 22, 2025 09:45
@nirinchev nirinchev force-pushed the ni/integration-insert-many branch from 3084bc0 to e5b67cf Compare April 22, 2025 09:47
@nirinchev nirinchev merged commit d7021bd into main Apr 22, 2025
5 checks passed
@nirinchev nirinchev deleted the ni/integration-insert-many branch April 22, 2025 09:56
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.

3 participants