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

Fix Packet size mismatch! error on collection drop #2813

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move the Drop a collection test to the tests folder
  • Loading branch information
gedaiu committed Jan 27, 2025
commit 24d88cbffcc5aa5fa547559b47fe3c9bba16cba0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ examples/bench-mongodb/bench-mongodb
examples/bench-urlrouter/bench-urlrouter
*.exe

tests/mongodb/collection/tests
9 changes: 0 additions & 9 deletions mongodb/vibe/db/mongo/collection.d
Original file line number Diff line number Diff line change
Expand Up @@ -1313,15 +1313,6 @@ struct MongoCollection {
}
}

/// Drop a collection
@safe unittest {
import vibe.db.mongo.mongo;
auto client = connectMongoDB("127.0.0.1");
auto chunks = client.getCollection("test.fs.chunks");

chunks.drop;
}

/**
Specifies a level of isolation for read operations. For example, you can use read concern to only read data that has propagated to a majority of nodes in a replica set.

Expand Down
7 changes: 7 additions & 0 deletions tests/mongodb/collection/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "tests",
"description": "High level MongoDB collection tests for vibe.d",
"dependencies": {
"vibe-d:mongodb": {"path": "../../../"}
}
}
39 changes: 39 additions & 0 deletions tests/mongodb/collection/source/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/// Requires mongo service running on localhost with default port
/// Uses test database

module app;

import vibe.core.core;
import vibe.core.log;
import vibe.data.bson;
import vibe.db.mongo.mongo;

import std.algorithm : all, canFind, equal, map, sort;
import std.conv : to;
import std.encoding : sanitize;
import std.exception : assertThrown;


void runTest(ushort port)
{
MongoClient client = connectMongoDB("127.0.0.1", port);

/// Drop a collection
Copy link
Contributor

Choose a reason for hiding this comment

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

is this test only testing dropping non-existent collections?

Should probably drop it twice just in case if it randomly existed beforehand on CI. It should behave the same both times after all.

Otherwise it might make sense to also create a collection here.

auto chunks = client.getCollection("test.fs.chunks");
chunks.drop;
}

int main(string[] args)
{
int ret = 0;
ushort port = args.length > 1
? args[1].to!ushort
: MongoClientSettings.defaultPort;
runTask(() nothrow {
try runTest(port);
catch (Exception e) assert(false, e.toString());
finally exitEventLoop(true);
});
runEventLoop();
return ret;
}
Loading