-
Notifications
You must be signed in to change notification settings - Fork 1
chore: add integration tests for create-index #84
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
Conversation
Pull Request Test Coverage Report for Build 14591543426Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
src/tools/mongodb/create/createIndex.ts:13
- When 'name' is not provided, ensure that the tool automatically generates a default index name to match the expectations in integration tests. If provider.createIndexes does not generate a default name, add logic to compute and assign one.
name: z.string().optional().describe("The name of the index"),
src/tools/mongodb/metadata/connect.ts:38
- The removal of the error-throwing branch for non-string connection options eliminates explicit validation for invalid connection configurations. Consider reintroducing a proper error message or validation check for non-string inputs.
if (typeof connectionStringOrClusterName === "string") {
tests/integration/tools/mongodb/metadata/listCollections.test.ts:91
- [nitpick] Using integration.randomDbName() multiple times in the same test case assumes that it will always return the same value. Ensure that randomDbName() is stable within a test run to avoid intermittent test failures.
expect(content).toEqual(`No collections found for database "${integration.randomDbName()}". To create a collection, use the "create-collection" tool.`);
} else { | ||
throw new MongoDBError(ErrorCodes.InvalidParams, "Invalid connection options"); | ||
// TODO: |
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.
?
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 unchanged code, but it's the hook where we'd want to call any atlas API that would allow us to generate a connection string based on a cluster name (if possible).
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.
should we add some text to that todo then?
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.
The text we return from the next statement is pretty much what we would write in the TODO comment, but happy to update it and add a link to the issue.
src/tools/mongodb/mongodbTool.ts
Outdated
if (!provider && config.connectionString) { | ||
await this.connectToMongoDB(config.connectionString); | ||
provider = this.session.serviceProvider; |
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.
It seems you're assigning the same value, would you double check if this is needed?
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.
connectToMongoDB
- if successful - will set the session provider.
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.
is there a scenario where NodeDriverServiceProvider.connect
returns undefined? seems like it'd throw instead right (and not be caught by connectToMongoDB
)?
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.
Based on the types, if the promise resolves, we should get a valid NodeServiceProvider
and not undefined
. If the connect
attempt fails, this will throw an error which will eventually be bubbled up to the error handler of whatever tool the user was calling.
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.
do I understand correctly then that the second if (!this.session.serviceProvider)
would never occur? We could make the connectToMongoDB
return the provider and set it to the local provider variable (I guess going back to that..) to make that type logic work
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.
I changed it to always use this.session.serviceProvider
and removed the local provider
var.
src/tools/mongodb/mongodbTool.ts
Outdated
@@ -19,9 +19,10 @@ export abstract class MongoDBToolBase extends ToolBase { | |||
protected category: ToolCategory = "mongodb"; | |||
|
|||
protected async ensureConnected(): Promise<NodeDriverServiceProvider> { | |||
const provider = this.session.serviceProvider; | |||
let provider = this.session.serviceProvider; |
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.
maybe we should directly use this.session.serviceProvider
at all times to avoid confusion
No description provided.