Add unittest to IXSentryClient to lua backtrace parsing code

This commit is contained in:
Benjamin Sergeant 2019-10-26 10:54:47 -07:00
parent bbfa76a2c9
commit 081dd2c4bb
5 changed files with 25 additions and 11 deletions

View File

@ -1 +1 @@
7.2.0
7.2.1

View File

@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.
## [7.2.1] - 2019-10-26
- Add unittest to IXSentryClient to lua backtrace parsing code
## [7.2.0] - 2019-10-24
- Add cobra_metrics_to_redis sub-command to create streams for each cobra metric event being received.

View File

@ -17,7 +17,7 @@ namespace ix
SentryClient::SentryClient(const std::string& dsn)
: _dsn(dsn)
, _validDsn(false)
, _luaFrameRegex("\t([^/]+):([0-9]+): in function '([^/]+)'")
, _luaFrameRegex("\t([^/]+):([0-9]+): in function ['<]([^/]+)['>]")
{
const std::regex dsnRegex("(http[s]?)://([^:]+):([^@]+)@([^/]+)/([0-9]+)");
std::smatch group;

View File

@ -21,14 +21,14 @@ namespace ix
std::pair<HttpResponsePtr, std::string> send(const Json::Value& msg, bool verbose);
Json::Value parseLuaStackTrace(const std::string& stack);
private:
int64_t getTimestamp();
std::string computeAuthHeader();
std::string getIso8601();
std::string computePayload(const Json::Value& msg);
Json::Value parseLuaStackTrace(const std::string& stack);
std::string _dsn;
bool _validDsn;
std::string _url;

View File

@ -2,28 +2,38 @@
* IXSentryClientTest.cpp
* Author: Benjamin Sergeant
* Copyright (c) 2019 Machine Zone. All rights reserved.
*
* (cd .. ; make) && ../build/test/ixwebsocket_unittest sentry
*/
#include "IXTest.h"
#include "catch.hpp"
#include <iostream>
#include <string.h>
#include <ixsentry/IXSentryClient.h>
using namespace ix;
namespace ix
{
TEST_CASE("sentry", "[sentry]")
{
SECTION("Attempt to perform nil")
SECTION("Attempt to index nil")
{
#if 0
SentryClient sentryClient;
std::string stack = "";
SentryClient sentryClient("");
std::string stack = "Attempt to index nil[overlay]!\nstack traceback:\n\tfoo.lua:2661: in function 'getFoo'\n\tfoo.lua:1666: in function 'onUpdate'\n\tfoo.lua:1751: in function <foo.lua:1728>";
auto frames = sentryClient.parseLuaStackTrace(stack);
REQUIRE(frames.size() > 0);
#endif
REQUIRE(frames.size() == 3);
}
SECTION("Attempt to perform nil")
{
SentryClient sentryClient("");
std::string stack = "Attempt to perform nil - 1572111278.299\nstack traceback:\n\tfoo.lua:57: in function <foo.lua:53>";
auto frames = sentryClient.parseLuaStackTrace(stack);
REQUIRE(frames.size() == 1);
}
}