rework client using async api
This commit is contained in:
+2
-24
@@ -1,24 +1,2 @@
|
||||
# Automation test
|
||||
|
||||
set(AT_SRCS
|
||||
client_autotest.cc
|
||||
client_timeout_autotest.cc
|
||||
main.cc
|
||||
)
|
||||
|
||||
# Common libraries to link.
|
||||
set(AT_LIBS
|
||||
webcc
|
||||
jsoncpp
|
||||
GTest::GTest)
|
||||
|
||||
if(UNIX)
|
||||
# Add `-ldl` for Linux to avoid "undefined reference to `dlopen'".
|
||||
set(AT_LIBS ${AT_LIBS} ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
||||
set(AT_TARGET_NAME autotest)
|
||||
|
||||
add_executable(${AT_TARGET_NAME} ${AT_SRCS})
|
||||
target_link_libraries(${AT_TARGET_NAME} ${AT_LIBS})
|
||||
set_target_properties(${AT_TARGET_NAME} PROPERTIES FOLDER "Tests")
|
||||
add_subdirectory(client_autotest)
|
||||
add_subdirectory(client_timeout_autotest)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
set(SRCS
|
||||
client_autotest.cc
|
||||
main.cc
|
||||
)
|
||||
|
||||
# Common libraries to link.
|
||||
set(LIBS
|
||||
webcc
|
||||
jsoncpp
|
||||
GTest::GTest
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
# Add `-ldl` for Linux to avoid "undefined reference to `dlopen'".
|
||||
set(LIBS ${LIBS} ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
||||
set(TARGET_NAME client_autotest)
|
||||
|
||||
add_executable(${TARGET_NAME} ${SRCS})
|
||||
|
||||
target_link_libraries(${TARGET_NAME} ${LIBS})
|
||||
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests")
|
||||
@@ -0,0 +1,22 @@
|
||||
set(SRCS
|
||||
client_timeout_autotest.cc
|
||||
main.cc
|
||||
)
|
||||
|
||||
# Common libraries to link.
|
||||
set(LIBS
|
||||
webcc
|
||||
jsoncpp
|
||||
GTest::GTest
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
# Add `-ldl` for Linux to avoid "undefined reference to `dlopen'".
|
||||
set(LIBS ${LIBS} ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
||||
set(TARGET_NAME client_timeout_autotest)
|
||||
|
||||
add_executable(${TARGET_NAME} ${SRCS})
|
||||
target_link_libraries(${TARGET_NAME} ${LIBS})
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests")
|
||||
+3
-3
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
const char* kData = "Hello, World!";
|
||||
const char* const kData = "Hello, World!";
|
||||
|
||||
const std::uint16_t kPort = 8080;
|
||||
|
||||
@@ -83,8 +83,8 @@ TEST_F(ClientTimeoutTest, NoTimeout) {
|
||||
TEST_F(ClientTimeoutTest, Timeout) {
|
||||
webcc::ClientSession session;
|
||||
|
||||
// Change timeout to 1s.
|
||||
session.set_timeout(1);
|
||||
// Change read timeout to 1s.
|
||||
session.set_read_timeout(1);
|
||||
|
||||
webcc::ResponsePtr r;
|
||||
bool timeout = false;
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "webcc/logger.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Set webcc::LOG_CONSOLE to enable logging.
|
||||
WEBCC_LOG_INIT("", 0);
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user