Skip to content

Commit

Permalink
Added a mock sharedInstance to fix watchOS crash
Browse files Browse the repository at this point in the history
  • Loading branch information
mbruin-NR committed Dec 17, 2024
1 parent 3945ad4 commit 000d233
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#import "NRMACustomEvent.h"
#import "NRMARequestEvent.h"
#import "NRMAInteractionEvent.h"
#import "NewRelicAgentInternal.h"
#import <OCMock/OCMock.h>

#import "BlockAttributeValidator.h"
#import "NRMAFlags.h"
Expand Down Expand Up @@ -65,8 +67,12 @@ - (nullable instancetype)initWithCoder:(nonnull NSCoder *)coder {
@end

@interface PersistentStoreTests : XCTestCase
@property id mockNewRelicInternals;

@end

static NewRelicAgentInternal* _sharedInstance;

@implementation PersistentStoreTests {
BlockAttributeValidator *agreeableAttributeValidator;
}
Expand All @@ -77,7 +83,11 @@ @implementation PersistentStoreTests {

- (void)setUp {
[super setUp];

self.mockNewRelicInternals = [OCMockObject mockForClass:[NewRelicAgentInternal class]];
_sharedInstance = [[NewRelicAgentInternal alloc] init];
_sharedInstance.analyticsController = [[NRMAAnalytics alloc] initWithSessionStartTimeMS:0.0];
[[[[self.mockNewRelicInternals stub] classMethod] andReturn:_sharedInstance] sharedInstance];

if(agreeableAttributeValidator == nil) {
agreeableAttributeValidator = [[BlockAttributeValidator alloc] initWithNameValidator:^BOOL(NSString *) {
return YES;
Expand Down

0 comments on commit 000d233

Please sign in to comment.