-
-
Notifications
You must be signed in to change notification settings - Fork 355
fix(ios): setUser to null works with null introduced in RN 0.77.1 #4567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
846f4b2
fix(ios): setUser to null works with null introduced in RN 0.77.1
krystofwoldrich 1c26bdd
add tests
krystofwoldrich 6029e09
fix(changelog): Update PR reference for iOS setUser fix
krystofwoldrich 792a25c
add more tests
krystofwoldrich 03de9b5
fix log
krystofwoldrich 0f433a0
fix c format
krystofwoldrich 854d256
fix test name
krystofwoldrich 926421f
fix syntax
krystofwoldrich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentry+Test.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #import <RNSentry/RNSentry.h> | ||
|
|
||
| @interface | ||
| RNSentry (RNSentryInternal) | ||
|
|
||
| + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys | ||
| otherUserKeys:(NSDictionary *)userDataKeys; | ||
|
|
||
| @end |
110 changes: 110 additions & 0 deletions
110
packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryUser.mm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| #import "RNSentry+Test.h" | ||
| #import "RNSentryTests.h" | ||
| #import <XCTest/XCTest.h> | ||
|
|
||
| @interface RNSentryUserTests : XCTestCase | ||
| @end | ||
|
|
||
| @implementation RNSentryUserTests | ||
|
|
||
| - (void)testValidUser | ||
| { | ||
| SentryUser *expected = [[SentryUser alloc] init]; | ||
| [expected setUserId:@"123"]; | ||
| [expected setIpAddress:@"192.168.1.1"]; | ||
| [expected setEmail:@"[email protected]"]; | ||
| [expected setUsername:@"testuser"]; | ||
| [expected setSegment:@"testsegment"]; | ||
| [expected setData:@{ | ||
| @"foo" : @"bar", | ||
| @"baz" : @123, | ||
| @"qux" : @[ @"a", @"b", @"c" ], | ||
| }]; | ||
|
|
||
| SentryUser *actual = [RNSentry userFrom:@{ | ||
| @"id" : @"123", | ||
| @"ip_address" : @"192.168.1.1", | ||
| @"email" : @"[email protected]", | ||
| @"username" : @"testuser", | ||
| @"segment" : @"testsegment", | ||
| } | ||
| otherUserKeys:@{ | ||
| @"foo" : @"bar", | ||
| @"baz" : @123, | ||
| @"qux" : @[ @"a", @"b", @"c" ], | ||
| }]; | ||
|
|
||
| XCTAssertTrue([actual isEqualToUser:expected]); | ||
| } | ||
|
|
||
| - (void)testNilUser | ||
| { | ||
| SentryUser *actual = [RNSentry userFrom:nil otherUserKeys:nil]; | ||
| XCTAssertNil(actual); | ||
| } | ||
|
|
||
| - (void)testNullUser | ||
| { | ||
| SentryUser *actual = [RNSentry userFrom:(NSDictionary *)[NSNull null] otherUserKeys:nil]; | ||
| XCTAssertNil(actual); | ||
| } | ||
|
|
||
| - (void)testEmptyUser | ||
| { | ||
| SentryUser *expected = [[SentryUser alloc] init]; | ||
| [expected setData:@{}]; | ||
|
|
||
| SentryUser *actual = [RNSentry userFrom:@{} otherUserKeys:@{}]; | ||
| XCTAssertTrue([actual isEqualToUser:expected]); | ||
| } | ||
|
|
||
| - (void)testInvalidUser | ||
| { | ||
| SentryUser *expected = [[SentryUser alloc] init]; | ||
|
|
||
| SentryUser *actual = [RNSentry userFrom:@{ | ||
| @"id" : @123, | ||
| @"ip_address" : @ {}, | ||
| @"email" : @ {}, | ||
| @"username" : @ {}, | ||
| @"segment" : @[], | ||
| } | ||
| otherUserKeys:nil]; | ||
|
|
||
| XCTAssertTrue([actual isEqualToUser:expected]); | ||
| } | ||
|
|
||
| - (void)testPartiallyInvalidUser | ||
| { | ||
| SentryUser *expected = [[SentryUser alloc] init]; | ||
| [expected setUserId:@"123"]; | ||
|
|
||
| SentryUser *actual = [RNSentry userFrom:@{ | ||
| @"id" : @"123", | ||
| @"ip_address" : @ {}, | ||
| @"email" : @ {}, | ||
| @"username" : @ {}, | ||
| @"segment" : @[], | ||
| } | ||
| otherUserKeys:nil]; | ||
|
|
||
| XCTAssertTrue([actual isEqualToUser:expected]); | ||
| } | ||
|
|
||
| - (void)testNullValuesUser | ||
| { | ||
| SentryUser *expected = [[SentryUser alloc] init]; | ||
|
|
||
| SentryUser *actual = [RNSentry userFrom:@{ | ||
| @"id" : [NSNull null], | ||
| @"ip_address" : [NSNull null], | ||
| @"email" : [NSNull null], | ||
| @"username" : [NSNull null], | ||
| @"segment" : [NSNull null], | ||
| } | ||
| otherUserKeys:nil]; | ||
|
|
||
| XCTAssertTrue([actual isEqualToUser:expected]); | ||
| } | ||
|
|
||
| @end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.