From f976848af6537f1b7dcb992b42a2a92f5cb9d491 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Fri, 20 Dec 2024 11:21:48 +0200 Subject: [PATCH] Add tests for new interface methods --- .../Private/Tests/SentrySubsystem.spec.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plugin-dev/Source/Sentry/Private/Tests/SentrySubsystem.spec.cpp b/plugin-dev/Source/Sentry/Private/Tests/SentrySubsystem.spec.cpp index 6ebe1fd7..d7aa483d 100644 --- a/plugin-dev/Source/Sentry/Private/Tests/SentrySubsystem.spec.cpp +++ b/plugin-dev/Source/Sentry/Private/Tests/SentrySubsystem.spec.cpp @@ -9,6 +9,7 @@ #include "UObject/UObjectGlobals.h" #include "Misc/AutomationTest.h" +#include "Misc/DateTime.h" #include "Engine/Engine.h" #if WITH_AUTOMATION_TESTS @@ -80,6 +81,13 @@ void SentrySubsystemSpec::Define() TestNotNull("Span is non-null", span); TestFalse("Span is not finished", span->IsFinished()); + USentrySpan* childSpan = span->StartChildWithTimestamp(TEXT("Automation child span"), TEXT("Description text"), FDateTime::UtcNow().ToUnixTimestamp()); + TestNotNull("Child span is non-null", childSpan); + TestFalse("Child span is not finished", childSpan->IsFinished()); + + childSpan->FinishWithTimestamp(FDateTime::UtcNow().ToUnixTimestamp()); + TestTrue("Child span is finished", childSpan->IsFinished()); + span->Finish(); TestTrue("Span is finished", span->IsFinished()); @@ -99,6 +107,19 @@ void SentrySubsystemSpec::Define() transaction->Finish(); TestTrue("Transaction is finished", transaction->IsFinished()); }); + + It("should be started and finished with specific context and timings", [this]() + { + USentryTransactionContext* transactionContext = NewObject(); + transactionContext->Initialize(TEXT("Automation transaction"), TEXT("Automation operation")); + + USentryTransaction* transaction = SentrySubsystem->StartTransactionWithContextAndTimestamp(transactionContext, FDateTime::UtcNow().ToUnixTimestamp()); + TestNotNull("Transaction is non-null", transaction); + TestFalse("Transaction is not finished", transaction->IsFinished()); + + transaction->FinishWithTimestamp(FDateTime::UtcNow().ToUnixTimestamp()); + TestTrue("Transaction is finished", transaction->IsFinished()); + }); }); Describe("Transaction context", [this]()