36 lines
1.4 KiB
C++
36 lines
1.4 KiB
C++
#include <gtest/gtest.h>
|
|
|
|
#include <string>
|
|
|
|
#include "../plugins/alarm/actions/external_api_action.h"
|
|
|
|
namespace rk3588 {
|
|
namespace {
|
|
|
|
TEST(ExternalApiActionTest, BuildsSuccessLogLineWithContext) {
|
|
const std::string line = BuildExternalApiResultLogLine(
|
|
"send ok", "cam1_alarm_42_7", "known_person:reg_001", "http://example/pic.jpg",
|
|
"http://example/clip.mp4", 200, "");
|
|
|
|
EXPECT_NE(line.find("send ok"), std::string::npos);
|
|
EXPECT_NE(line.find("event_id=cam1_alarm_42_7"), std::string::npos);
|
|
EXPECT_NE(line.find("http=200"), std::string::npos);
|
|
EXPECT_NE(line.find("alarm_content=known_person:reg_001"), std::string::npos);
|
|
EXPECT_NE(line.find("pic_url=http://example/pic.jpg"), std::string::npos);
|
|
EXPECT_NE(line.find("video_url=http://example/clip.mp4"), std::string::npos);
|
|
}
|
|
|
|
TEST(ExternalApiActionTest, BuildsFailureLogLineWithError) {
|
|
const std::string line = BuildExternalApiResultLogLine(
|
|
"send failed", "cam1_alarm_51_8", "unknown_face", "", "", 500, "timeout");
|
|
|
|
EXPECT_NE(line.find("send failed"), std::string::npos);
|
|
EXPECT_NE(line.find("event_id=cam1_alarm_51_8"), std::string::npos);
|
|
EXPECT_NE(line.find("http=500"), std::string::npos);
|
|
EXPECT_NE(line.find("error=timeout"), std::string::npos);
|
|
EXPECT_NE(line.find("alarm_content=unknown_face"), std::string::npos);
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace rk3588
|