11import path from "path" ;
22import fs from "fs/promises" ;
3- import type { ObjectId } from "bson" ;
4- import { EJSON , Long } from "bson" ;
3+ import { EJSON , Long , ObjectId } from "bson" ;
54import { describe , expect , it , beforeEach , afterAll } from "vitest" ;
65import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
76import { defaultTestConfig , getDataFromUntrustedContent , resourceChangedNotification , timeout } from "../helpers.js" ;
@@ -16,17 +15,20 @@ const userConfig: UserConfig = {
1615 exportCleanupIntervalMs : 300 ,
1716} ;
1817
19- const docs = [
20- { name : "foo" , longNumber : new Long ( 1234 ) } ,
21- { name : "bar" , bigInt : new Long ( 123412341234 ) } ,
22- ] ;
23-
2418describeWithMongoDB (
2519 "exported-data resource" ,
2620 ( integration ) => {
21+ let docs : { _id : ObjectId ; name : string ; longNumber ?: Long ; bigInt ?: Long } [ ] ;
22+ let collection : string ;
23+
2724 beforeEach ( async ( ) => {
2825 const mongoClient = integration . mongoClient ( ) ;
29- await mongoClient . db ( "db" ) . collection ( "coll" ) . insertMany ( docs ) ;
26+ collection = new ObjectId ( ) . toString ( ) ;
27+ docs = [
28+ { name : "foo" , longNumber : new Long ( 1234 ) , _id : new ObjectId ( ) } ,
29+ { name : "bar" , bigInt : new Long ( 123412341234 ) , _id : new ObjectId ( ) } ,
30+ ] ;
31+ await mongoClient . db ( "db" ) . collection ( collection ) . insertMany ( docs ) ;
3032 } ) ;
3133
3234 afterAll ( async ( ) => {
@@ -67,7 +69,7 @@ describeWithMongoDB(
6769 name : "export" ,
6870 arguments : {
6971 database : "db" ,
70- collection : "coll" ,
72+ collection,
7173 exportTitle : "Export for db.coll" ,
7274 exportTarget : [ { name : "find" , arguments : { } } ] ,
7375 } ,
@@ -106,7 +108,7 @@ describeWithMongoDB(
106108 name : "export" ,
107109 arguments : {
108110 database : "db" ,
109- collection : "coll" ,
111+ collection,
110112 exportTitle : "Export for db.coll" ,
111113 exportTarget : [ { name : "find" , arguments : { } } ] ,
112114 } ,
@@ -143,7 +145,7 @@ describeWithMongoDB(
143145 name : "export" ,
144146 arguments : {
145147 database : "big" ,
146- collection : "coll" ,
148+ collection,
147149 exportTitle : "Export for big.coll" ,
148150 exportTarget : [ { name : "find" , arguments : { } } ] ,
149151 } ,
0 commit comments