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 Test Failures due to Update 9 Changes #250

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
distribution = "2201.7.0"
org = "ballerinax"
name = "mongodb"
version = "5.0.0"
version = "5.0.1"
license= ["Apache-2.0"]
authors = ["Ballerina"]
keywords = ["IT Operations/Databases", "Cost/Freemium"]
Expand All @@ -15,8 +15,8 @@ graalvmCompatible = true
[[platform.java17.dependency]]
groupId = "io.ballerina.lib"
artifactId = "mongodb-native"
version = "5.0.0"
path = "../native/build/libs/mongodb-native-5.0.0.jar"
version = "5.0.1-SNAPSHOT"
path = "../native/build/libs/mongodb-native-5.0.1-SNAPSHOT.jar"

[[platform.java17.dependency]]
groupId = "org.mongodb"
Expand Down
6 changes: 3 additions & 3 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.8.6"
distribution-version = "2201.8.0"

[[package]]
org = "ballerina"
name = "crypto"
version = "2.5.0"
version = "2.6.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
Expand Down Expand Up @@ -99,7 +99,7 @@ dependencies = [
[[package]]
org = "ballerinax"
name = "mongodb"
version = "5.0.0"
version = "5.0.1"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
Expand Down
25 changes: 13 additions & 12 deletions ballerina/tests/03_collection_tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ isolated function testInsertAndFind() returns error? {
}

@test:Config {
groups: ["collection", "insert", "insertOne", "find", "projection", "test"]
groups: ["collection", "insert", "insertOne", "find", "projection"]
}
isolated function testFindOne() returns error? {
Database database = check mongoClient->getDatabase("testFindOneDB");
Expand Down Expand Up @@ -361,20 +361,21 @@ isolated function testUpdateUnset() returns error? {
updateResult = check collection->updateOne({name: "Walter White"}, {"unset": {"address.country": ""}});
test:assertEquals(updateResult.matchedCount, 1);
test:assertEquals(updateResult.modifiedCount, 1);
result = check collection->find({name: "Walter White"});
stream<record {|anydata...;|}, error?> findResult = check collection->find({name: "Walter White"});

// Trapping the type conversion error and checking for the relevant error message.
// This is to confirm the field is removed from the document.
record {Person value;}|error? movieResult = trap result.next();
if movieResult !is error {
test:assertFail("Expected an error");
record {|anydata...;|}? movieResult = check findResult.next();
if movieResult is () {
test:assertFail("Expected a record value from the stream");
}
var detail = movieResult.detail();
if detail !is anydata {
test:assertFail("Expected anydata type for error detail");
if movieResult.hasKey("address") {
var address = movieResult["address"];
if address !is map<anydata> {
test:assertFail("Expected a map value for the `address` field");
}
if address.hasKey("country") {
test:assertFail("Expected the `country` field to be removed from the `address` field");
}
}
string message = detail["message"].toString();
test:assertTrue(message.includes("missing required field 'address.country' of type 'string'"));
check result.close();
check collection->drop();
check database->drop();
Expand Down
Loading