test(compat-logic): add compat framework and httpweb/session tests - #768
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Sorry @pengfeixx, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Add tests for lifecycle PluginManagerPrivate, zrpc channel/dispatcher, common struct serialization, WebBinder helpers, FileClient/FileServer edge cases and ProtoClient/ProtoServer data operations. 新增compat框架和httpweb/session模块测试,覆盖生命周期插件管理、 zrpc通道/分发器、通用结构序列化、WebBinder辅助方法、文件客户端/ 服务端边界场景和ProtoClient/ProtoServer数据操作。 Log: 添加compat和logic模块覆盖率测试 Influence: 仅新增测试文件,不影响现有功能,提升compat和logic模块覆盖率。
da9c348 to
53f7b9a
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 针对 session_test.cpp 中硬编码端口和直接访问私有成员的改进建议
// 建议在测试基类中动态分配端口或使用环境变量
class SessionTest : public ::testing::Test {
protected:
std::shared_ptr<NetUtil::Asio::Service> service;
std::shared_ptr<NetUtil::Asio::SSLContext> context;
std::shared_ptr<TestSessionCallbacks> callbacks;
int testPort;
int getAvailablePort() {
// 简单的动态端口获取逻辑示例
// 实际项目中可使用更健壮的端口管理工具或绑定到端口0后获取实际端口
return 19000 + (rand() % 1000);
}
void SetUp() override
{
testPort = getAvailablePort();
service = std::make_shared<NetUtil::Asio::Service>();
service->Start();
context = std::make_shared<NetUtil::Asio::SSLContext>(asio::ssl::context::tlsv12);
callbacks = std::make_shared<TestSessionCallbacks>();
}
void TearDown() override
{
callbacks.reset();
service->Stop();
}
void insertSession(ProtoServer &server, const std::string &ip)
{
BaseKit::UUID uid = BaseKit::UUID::Sequential();
// 假设 _sessionids_lock 和 _session_ids 可访问
// 如果不可访问,应通过 ProtoServer 提供的测试接口或友元类访问
std::unique_lock<std::shared_mutex> locker(server._sessionids_lock);
server._session_ids.insert(std::make_pair(ip, uid));
}
};
TEST_F(SessionTest, ProtoServerConstruct)
{
// 使用动态端口
ProtoServer server(service, context, testPort);
SUCCEED();
} |
|
Note
详情{
"tests/compat/commonstruct_test.cpp": [
{
"line": " src.token = \"tkn\";",
"line_number": 76,
"rule": "S106",
"reason": "Var naming | 8114f75dbc"
}
],
"tests/compat/lifecycle_private_test.cpp": [
{
"line": " metaData.insert(kPluginUrlLink, \"http://example.com\");",
"line_number": 78,
"rule": "S35",
"reason": "Url link | f7d44315b2"
},
{
"line": " EXPECT_EQ(meta->urlLink(), \"http://example.com\");",
"line_number": 91,
"rule": "S35",
"reason": "Url link | f7d44315b2"
}
]
} |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
Add tests for lifecycle PluginManagerPrivate, zrpc channel/dispatcher, common struct serialization, WebBinder helpers, FileClient/FileServer edge cases and ProtoClient/ProtoServer data operations.
新增compat框架和httpweb/session模块测试,覆盖生命周期插件管理、
zrpc通道/分发器、通用结构序列化、WebBinder辅助方法、文件客户端/
服务端边界场景和ProtoClient/ProtoServer数据操作。
Log: 添加compat和logic模块覆盖率测试
Influence: 仅新增测试文件,不影响现有功能,提升compat和logic模块覆盖率。