Skip to content

Commit

Permalink
Add server integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacquwes committed Sep 28, 2023
1 parent c7f0d49 commit 43c045f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
4 changes: 3 additions & 1 deletion tests/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ add_executable(
${SOURCES}
)

target_link_libraries(integration_tests PRIVATE shared)
target_link_libraries(integration_tests PRIVATE asio)
target_link_libraries(integration_tests PRIVATE client)
target_link_libraries(integration_tests PRIVATE server)
target_link_libraries(integration_tests PRIVATE shared)
target_link_libraries(integration_tests PRIVATE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)

gtest_discover_tests(integration_tests)
34 changes: 34 additions & 0 deletions tests/integration/integration_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
#include <thread>

#include <asio.hpp>
#include <client.h>
#include <coroutine.h>
#include <gtest/gtest.h>
#include <server.h>

int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

TEST(integration_tests, connect_client_to_server)
{
asio::io_context io_context;

std::jthread server_thread([&]()
{
pine::server server(io_context);

server.on_connection_attempt([](auto& server, auto& client) -> async_task
{
server.stop();
SUCCEED();
co_return;
});

server.listen();

FAIL();
});

pine::client client("test", io_context);

if(!client.connect())
FAIL();

client.disconnect();
}
3 changes: 0 additions & 3 deletions tests/integration/server_integration_tests.cpp

This file was deleted.

0 comments on commit 43c045f

Please sign in to comment.