Skip to content
Snippets Groups Projects
Commit a2b0e933 authored by kamathmanu's avatar kamathmanu
Browse files

Continue fixing ClientAPI tests; Rearranged nesting order since the PUT wasn't...

Continue fixing ClientAPI tests; Rearranged nesting order since the PUT wasn't working when nested in the join_room. TODO: figure out why the room is not added to directory
parent ddba818c
No related branches found
No related tags found
No related merge requests found
Pipeline #306 passed
...@@ -986,6 +986,7 @@ Client::put_room_visibility(const std::string &room_id, ...@@ -986,6 +986,7 @@ Client::put_room_visibility(const std::string &room_id,
+ mtx::client::utils::url_encode(room_id); + mtx::client::utils::url_encode(room_id);
std::cout << api_path << "\n"; std::cout << api_path << "\n";
put<mtx::requests::RoomVisibility>(api_path, req, cb); put<mtx::requests::RoomVisibility>(api_path, req, cb);
std::cout << "Does ths work?\n";
} }
void void
......
...@@ -1599,7 +1599,7 @@ TEST(ClientAPI, PublicRooms) ...@@ -1599,7 +1599,7 @@ TEST(ClientAPI, PublicRooms)
mtx::requests::CreateRoom req; mtx::requests::CreateRoom req;
req.name = "Public Room"; req.name = "Public Room";
req.topic = "Test"; req.topic = "Test";
req.visibility = Visibility::Public; req.visibility = Visibility::Private;
req.invite = {"@bob:localhost"}; req.invite = {"@bob:localhost"};
// req.room_alias_name = "foo"; // req.room_alias_name = "foo";
...@@ -1608,57 +1608,113 @@ TEST(ClientAPI, PublicRooms) ...@@ -1608,57 +1608,113 @@ TEST(ClientAPI, PublicRooms)
check_error(err); check_error(err);
auto room_id = res.room_id; auto room_id = res.room_id;
bob->join_room(room_id.to_string(), [alice, bob, room_id](const mtx::responses::RoomId &, RequestErr err) { // TEST 1: endpoints to set and get the visibility of the room we just created
check_error(err); mtx::requests::RoomVisibility r;
r.visibility = mtx::requests::Visibility::Public;
// TEST 1: endpoints to set and get the visibility of the room we just created
mtx::requests::RoomVisibility r;
r.visibility = mtx::requests::Visibility::Private;
std::cout << "HERE\n"; std::cout << "HERE\n";
alice->put_room_visibility(room_id.to_string(), r, [alice, bob, room_id](RequestErr err){ alice->put_room_visibility(room_id.to_string(), r, [alice, bob, room_id](RequestErr err){
check_error(err); check_error(err);
std::cout << "NOW IM HERE\n"; std::cout << "PLS WORK!\n";
alice->get_room_visibility alice->get_room_visibility
("", [alice, room_id](const mtx::responses::RoomVisibility &, RequestErr err) { ("", [alice, room_id](const mtx::responses::RoomVisibility &, RequestErr err) {
check_error(err); ASSERT_TRUE(err);
// ASSERT_TRUE(err); EXPECT_EQ(mtx::errors::to_string(err->matrix_error.errcode),
// EXPECT_EQ(mtx::errors::to_string(err->matrix_error.errcode), "M_NOT_FOUND");
// "M_NOT_FOUND");
}); });
// alice->get_room_visibility std::atomic<bool> done = false;
// (room_id, [alice](const mtx::responses::RoomVisibility &res, RequestErr err){
alice->get_room_visibility
(room_id.to_string(), [alice, bob, room_id, &done](const mtx::responses::RoomVisibility &res, RequestErr err){
// check_error(err); check_error(err);
// EXPECT_EQ(visibilityToString(res.visibility), "public"); EXPECT_EQ(visibilityToString(res.visibility), "public");
done = true;
// // TEST 2: endpoints to add and list the public rooms on the server // TEST 2: endpoints to add and list the public rooms on the server
// mtx::requests::PublicRooms room_req; mtx::requests::PublicRooms room_req;
// room_req.limit = 1; room_req.limit = 1;
// room_req.include_all_networks = true; room_req.include_all_networks = true;
// json j = room_req; json j = room_req;
// std::cout << j.dump(4) << "\n"; std::cout << j.dump(4) << "\n";
// alice->post_public_rooms while (!done) {
// (room_req, [alice](const mtx::responses::PublicRooms &, RequestErr err) { sleep();
// check_error(err); }
// alice->get_public_rooms alice->post_public_rooms
// ([alice](const mtx::responses::PublicRooms &res, RequestErr err) { (room_req, [alice, bob, room_id, room_req](const mtx::responses::PublicRooms &, RequestErr err) {
// check_error(err); check_error(err);
// std::cout << res.chunk.size() << std::endl;
// EXPECT_EQ(res.chunk[0].name, "Public Room"); std::cout << "POST req\n";
// EXPECT_EQ(res.chunk[0].topic, "Test");
// EXPECT_EQ(res.chunk[0].num_joined_members, 2); // alice->get_public_rooms
// }, "", 1); // ([alice, bob, room_id](const mtx::responses::PublicRooms &res, RequestErr err) {
// }); // check_error(err);
// }); // std::cout << res.chunk.size() << std::endl;
// EXPECT_EQ(res.chunk[0].name, "Public Room");
// EXPECT_EQ(res.chunk[0].topic, "Test");
// EXPECT_EQ(res.chunk[0].num_joined_members, 2);
// }, "", 1);
});
});
}); });
});
// bob->join_room(room_id.to_string(), [alice, bob, room_id](const mtx::responses::RoomId &, RequestErr err) {
// check_error(err);
// // TEST 1: endpoints to set and get the visibility of the room we just created
// mtx::requests::RoomVisibility r;
// r.visibility = mtx::requests::Visibility::Private;
// std::cout << "HERE\n";
// alice->put_room_visibility(room_id.to_string(), r, [alice, bob, room_id](RequestErr err){
// check_error(err);
// std::cout << "PLS WORK!\n";
// alice->get_room_visibility
// ("", [alice, room_id](const mtx::responses::RoomVisibility &, RequestErr err) {
// check_error(err);
// ASSERT_TRUE(err);
// EXPECT_EQ(mtx::errors::to_string(err->matrix_error.errcode),
// "M_NOT_FOUND");
// });
// // alice->get_room_visibility
// // (room_id, [alice](const mtx::responses::RoomVisibility &res, RequestErr err){
// // check_error(err);
// // EXPECT_EQ(visibilityToString(res.visibility), "public");
// // // TEST 2: endpoints to add and list the public rooms on the server
// // mtx::requests::PublicRooms room_req;
// // room_req.limit = 1;
// // room_req.include_all_networks = true;
// // json j = room_req;
// // std::cout << j.dump(4) << "\n";
// // alice->post_public_rooms
// // (room_req, [alice](const mtx::responses::PublicRooms &, RequestErr err) {
// // check_error(err);
// // alice->get_public_rooms
// // ([alice](const mtx::responses::PublicRooms &res, RequestErr err) {
// // check_error(err);
// // std::cout << res.chunk.size() << std::endl;
// // EXPECT_EQ(res.chunk[0].name, "Public Room");
// // EXPECT_EQ(res.chunk[0].topic, "Test");
// // EXPECT_EQ(res.chunk[0].num_joined_members, 2);
// // }, "", 1);
// // });
// // });
// });
// });
}); });
alice->close(); alice->close();
bob->close(); bob->close();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment