diff options
author | aozeritsky <aozeritsky@ydb.tech> | 2023-08-21 17:15:26 +0300 |
---|---|---|
committer | aozeritsky <aozeritsky@ydb.tech> | 2023-08-21 17:30:24 +0300 |
commit | 6128c83f475b712a95f262e363dd2d3681500a0e (patch) | |
tree | fb52e4fa7d0dccb6bc4e6ced2707e11bfaf2e4b3 /library/cpp/testing | |
parent | eac8ca1f552726198b4d7a21fcdecf8954339262 (diff) | |
download | ydb-6128c83f475b712a95f262e363dd2d3681500a0e.tar.gz |
Add yt into autobuild
Diffstat (limited to 'library/cpp/testing')
-rw-r--r-- | library/cpp/testing/CMakeLists.txt | 1 | ||||
-rw-r--r-- | library/cpp/testing/gtest/friend.h | 5 | ||||
-rw-r--r-- | library/cpp/testing/mock_server/CMakeLists.darwin-x86_64.txt | 19 | ||||
-rw-r--r-- | library/cpp/testing/mock_server/CMakeLists.linux-aarch64.txt | 20 | ||||
-rw-r--r-- | library/cpp/testing/mock_server/CMakeLists.linux-x86_64.txt | 20 | ||||
-rw-r--r-- | library/cpp/testing/mock_server/CMakeLists.txt | 17 | ||||
-rw-r--r-- | library/cpp/testing/mock_server/CMakeLists.windows-x86_64.txt | 19 | ||||
-rw-r--r-- | library/cpp/testing/mock_server/ut/server_ut.cpp | 40 | ||||
-rw-r--r-- | library/cpp/testing/mock_server/ut/ya.make | 11 |
9 files changed, 152 insertions, 0 deletions
diff --git a/library/cpp/testing/CMakeLists.txt b/library/cpp/testing/CMakeLists.txt index 70c5d112f1..6e9e24fec8 100644 --- a/library/cpp/testing/CMakeLists.txt +++ b/library/cpp/testing/CMakeLists.txt @@ -14,5 +14,6 @@ add_subdirectory(gtest) add_subdirectory(gtest_extensions) add_subdirectory(gtest_main) add_subdirectory(hook) +add_subdirectory(mock_server) add_subdirectory(unittest) add_subdirectory(unittest_main) diff --git a/library/cpp/testing/gtest/friend.h b/library/cpp/testing/gtest/friend.h new file mode 100644 index 0000000000..551a218be0 --- /dev/null +++ b/library/cpp/testing/gtest/friend.h @@ -0,0 +1,5 @@ +#pragma once + +// Using absolute path to gtest headers in order to allow using friend.h without PEERDIRing gtest. +#include <contrib/restricted/googletest/googletest/include/gtest/gtest_prod.h> + diff --git a/library/cpp/testing/mock_server/CMakeLists.darwin-x86_64.txt b/library/cpp/testing/mock_server/CMakeLists.darwin-x86_64.txt new file mode 100644 index 0000000000..a5d1538c15 --- /dev/null +++ b/library/cpp/testing/mock_server/CMakeLists.darwin-x86_64.txt @@ -0,0 +1,19 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-testing-mock_server) +target_link_libraries(cpp-testing-mock_server PUBLIC + contrib-libs-cxxsupp + yutil + cpp-http-misc + cpp-http-server +) +target_sources(cpp-testing-mock_server PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/testing/mock_server/server.cpp +) diff --git a/library/cpp/testing/mock_server/CMakeLists.linux-aarch64.txt b/library/cpp/testing/mock_server/CMakeLists.linux-aarch64.txt new file mode 100644 index 0000000000..c630a22d23 --- /dev/null +++ b/library/cpp/testing/mock_server/CMakeLists.linux-aarch64.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-testing-mock_server) +target_link_libraries(cpp-testing-mock_server PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + cpp-http-misc + cpp-http-server +) +target_sources(cpp-testing-mock_server PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/testing/mock_server/server.cpp +) diff --git a/library/cpp/testing/mock_server/CMakeLists.linux-x86_64.txt b/library/cpp/testing/mock_server/CMakeLists.linux-x86_64.txt new file mode 100644 index 0000000000..c630a22d23 --- /dev/null +++ b/library/cpp/testing/mock_server/CMakeLists.linux-x86_64.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-testing-mock_server) +target_link_libraries(cpp-testing-mock_server PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + cpp-http-misc + cpp-http-server +) +target_sources(cpp-testing-mock_server PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/testing/mock_server/server.cpp +) diff --git a/library/cpp/testing/mock_server/CMakeLists.txt b/library/cpp/testing/mock_server/CMakeLists.txt new file mode 100644 index 0000000000..f8b31df0c1 --- /dev/null +++ b/library/cpp/testing/mock_server/CMakeLists.txt @@ -0,0 +1,17 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-aarch64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + include(CMakeLists.darwin-x86_64.txt) +elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA) + include(CMakeLists.windows-x86_64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-x86_64.txt) +endif() diff --git a/library/cpp/testing/mock_server/CMakeLists.windows-x86_64.txt b/library/cpp/testing/mock_server/CMakeLists.windows-x86_64.txt new file mode 100644 index 0000000000..a5d1538c15 --- /dev/null +++ b/library/cpp/testing/mock_server/CMakeLists.windows-x86_64.txt @@ -0,0 +1,19 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-testing-mock_server) +target_link_libraries(cpp-testing-mock_server PUBLIC + contrib-libs-cxxsupp + yutil + cpp-http-misc + cpp-http-server +) +target_sources(cpp-testing-mock_server PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/testing/mock_server/server.cpp +) diff --git a/library/cpp/testing/mock_server/ut/server_ut.cpp b/library/cpp/testing/mock_server/ut/server_ut.cpp new file mode 100644 index 0000000000..74b3dcec05 --- /dev/null +++ b/library/cpp/testing/mock_server/ut/server_ut.cpp @@ -0,0 +1,40 @@ +#include <library/cpp/testing/mock_server/server.h> + +#include <library/cpp/http/simple/http_client.h> +#include <library/cpp/testing/unittest/registar.h> + +Y_UNIT_TEST_SUITE(Server) { + int i; + + Y_UNIT_TEST(pong) { + TPortManager pm; + ui16 port = pm.GetPort(80); + NMock::TMockServer server(port, []() { return new NMock::TPong; }); + + TKeepAliveHttpClient cl("localhost", port); + UNIT_ASSERT_VALUES_EQUAL(200, cl.DoGet("/ping")); + UNIT_ASSERT_VALUES_EQUAL(404, cl.DoGet("/kek")); + } + + Y_UNIT_TEST(custom) { + class TCustomReplier: public TRequestReplier { + public: + bool DoReply(const TReplyParams& params) override { + THttpResponse resp(HttpCodes::HTTP_OK); + resp.SetContent("everithing is ok"); + resp.OutTo(params.Output); + + return true; + } + }; + + TPortManager pm; + ui16 port = pm.GetPort(80); + NMock::TMockServer server(port, []() { return new TCustomReplier; }); + + TKeepAliveHttpClient cl("localhost", port); + TStringStream out; + UNIT_ASSERT_VALUES_EQUAL(200, cl.DoGet("/foo", &out)); + UNIT_ASSERT_VALUES_EQUAL("everithing is ok", out.Str()); + } +} diff --git a/library/cpp/testing/mock_server/ut/ya.make b/library/cpp/testing/mock_server/ut/ya.make new file mode 100644 index 0000000000..f4ee34458f --- /dev/null +++ b/library/cpp/testing/mock_server/ut/ya.make @@ -0,0 +1,11 @@ +UNITTEST_FOR(library/cpp/testing/mock_server) + +PEERDIR( + library/cpp/http/simple +) + +SRCS( + server_ut.cpp +) + +END() |