Skip to content

Commit

Permalink
test: Add missing test for transaction name (#2900)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipphofmann authored Apr 14, 2023
1 parent 65b8953 commit 8c50edb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryTransaction.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ - (instancetype)initWithTrace:(SentryTracer *)trace children:(NSArray<id<SentryS
}

if (self.trace) {
[serializedData setValue:self.trace.transactionContext.name forKey:@"transaction"];
serializedData[@"transaction"] = self.trace.transactionContext.name;

serializedData[@"transaction_info"] =
@{ @"source" : [self stringForNameSource:self.trace.transactionContext.nameSource] };
Expand Down
9 changes: 9 additions & 0 deletions Tests/SentryTests/Transaction/SentryTransactionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,13 @@ class SentryTransactionTests: XCTestCase {
let actualTransactionInfo = actual["transaction_info"] as? [String: String]
XCTAssertEqual(actualTransactionInfo?["source"], "component")
}

func testSerialize_TransactionName() {
let scope = Scope()
let transaction = fixture.getTransactionWith(scope: scope)
let actual = transaction.serialize()

let actualTransaction = actual["transaction"] as? String
XCTAssertEqual(actualTransaction, fixture.transactionName)
}
}

0 comments on commit 8c50edb

Please sign in to comment.