Skip to content

Commit 8a4f34e

Browse files
committed
tests: More verbosity to be able to analyse test failure.
1 parent 396bf85 commit 8a4f34e

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

devapi/tests/crud-t.cc

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,22 +2469,30 @@ TEST_F(Crud, single_document)
24692469
Schema sch = getSchema("test");
24702470
Collection coll = sch.createCollection("c1", true);
24712471

2472+
cout << "Adding documents..." << endl;
2473+
24722474
coll.remove("true").execute();
24732475

2474-
coll.add(R"({"_id":"id1", "name":"foo", "age": 1 })" )
2475-
.add(R"({"_id":"id2", "name":"bar", "age": 2 })" )
2476-
.add(R"({"_id":"id3", "name":"baz", "age": 3 })" )
2477-
.execute();
2476+
coll.add(R"({"_id":"id1", "name":"foo", "age": 1 })")
2477+
.add(R"({"_id":"id2", "name":"bar", "age": 2 })")
2478+
.add(R"({"_id":"id3", "name":"baz", "age": 3 })")
2479+
.execute();
2480+
2481+
cout << "getOne()" << endl;
24782482

24792483
EXPECT_EQ(string("foo"), coll.getOne("id1")["name"].get<string>());
24802484
EXPECT_EQ(string("bar"), coll.getOne("id2")["name"].get<string>());
24812485
EXPECT_TRUE(coll.getOne("idZ").isNull());
24822486

2487+
cout << "removeOne()" << endl;
2488+
24832489
EXPECT_EQ(1, coll.removeOne("id1").getAffectedItemsCount());
24842490
EXPECT_EQ(0, coll.removeOne("id1").getAffectedItemsCount());
24852491

24862492
EXPECT_TRUE(coll.getOne("id1").isNull());
24872493

2494+
cout << "replaceOne()" << endl;
2495+
24882496
// Replace existing document
24892497
EXPECT_EQ(1, coll.replaceOne(
24902498
"id3",
@@ -2493,6 +2501,8 @@ TEST_F(Crud, single_document)
24932501
EXPECT_EQ(string("qux"), coll.getOne("id3")["name"].get<string>());
24942502
EXPECT_EQ(4, coll.getOne("id3")["age"].get<int>());
24952503

2504+
cout << "replaceOne(): change id" << endl;
2505+
24962506
// Setting a different _id on document should throw error
24972507
// Document passed as string
24982508
EXPECT_THROW(coll.replaceOne("id3", "{\"_id\": \"id4\", \"name\": \"baz\" }"),
@@ -2508,13 +2518,20 @@ TEST_F(Crud, single_document)
25082518
// Document passed as DbDoc
25092519
EXPECT_THROW(coll.replaceOne("id3", DbDoc("{\"_id\": \"id4\", \"name\": \"baz\" }")),
25102520
Error);
2521+
2522+
cout << "getOne(): array" << endl;
2523+
25112524
EXPECT_EQ(string("qux"), coll.getOne("id3")["name"].get<string>());
25122525
EXPECT_EQ(string("id3"), coll.getOne("id3")["_id"].get<string>());
25132526

2527+
cout << "replaceOne(): non-existing" << endl;
2528+
25142529
// should affect none
25152530
EXPECT_EQ(0,
25162531
coll.replaceOne("id4", expr(R"({"name": "baz" })"))
25172532
.getAffectedItemsCount());
2533+
2534+
cout << "Done!" << endl;
25182535
}
25192536

25202537

0 commit comments

Comments
 (0)