Skip to content

Commit

Permalink
fix: fix testBadHarvestConfiguration test
Browse files Browse the repository at this point in the history
  • Loading branch information
cdillard-NewRelic committed Jan 11, 2024
1 parent c1e95ef commit 64f2013
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
26 changes: 22 additions & 4 deletions Agent/Harvester/DataStore/NRMAHarvesterConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ - (id) initWithDictionary:(NSDictionary*)dict
self.data_token = [[NRMADataToken alloc] init];
self.data_token.clusterAgentId = [[[dict valueForKey:kNRMA_DATA_TOKEN] objectAtIndex:0] longLongValue];
self.data_token.realAgentId = [[[dict valueForKey:kNRMA_DATA_TOKEN] objectAtIndex:1] longLongValue];
if ([dict objectForKey:kNRMA_ERROR_LIMIT]) {

if ([dict objectForKey:kNRMA_ERROR_LIMIT]) {
self.error_limit = [[dict valueForKey:kNRMA_ERROR_LIMIT] intValue];
}
else {
Expand All @@ -57,10 +57,28 @@ - (id) initWithDictionary:(NSDictionary*)dict
self.report_max_transaction_count = NRMA_DEFAULT_MAX_TRANSACTION_COUNT;
}

self.response_body_limit = [[dict valueForKey:kNRMA_RESPONSE_BODY_LIMIT] intValue];
if ([dict objectForKey:kNRMA_RESPONSE_BODY_LIMIT]) {
self.response_body_limit = [[dict valueForKey:kNRMA_RESPONSE_BODY_LIMIT] intValue];
}
else {
self.response_body_limit = NRMA_DEFAULT_RESPONSE_BODY_LIMIT;
}

self.server_timestamp = [[dict valueForKey:kNRMA_SERVER_TIMESTAMP] longLongValue];
self.stack_trace_limit = [[dict valueForKey:kNRMA_STACK_TRACE_LIMIT] intValue];
self.activity_trace_max_size =[[dict valueForKey:kNRMA_AT_MAX_SIZE] intValue];

if ([dict objectForKey:kNRMA_STACK_TRACE_LIMIT]) {
self.stack_trace_limit = [[dict valueForKey:kNRMA_STACK_TRACE_LIMIT] intValue];
}
else {
self.stack_trace_limit = NRMA_DEFAULT_STACK_TRACE_LIMIT;
}
if ([dict objectForKey:kNRMA_AT_MAX_SIZE]) {
self.activity_trace_max_size =[[dict valueForKey:kNRMA_AT_MAX_SIZE] intValue];
}
else {
self.activity_trace_max_size = NRMA_DEFAULT_ACTIVITY_TRACE_MAX_SIZE;
}

self.at_capture = [[NRMATraceConfigurations alloc] initWithArray:[dict valueForKey:kNRMA_AT_CAPTURE]];
self.activity_trace_min_utilization = [[dict valueForKey:KNRMA_AT_MIN_UTILIZATION] doubleValue];
self.encoding_key = [dict valueForKey:kNRMA_ENCODING_KEY];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,26 @@ - (void) testHarvestConfiguration
}

- (void) testBadHarvestConfiguration {
// add a test that tests what happens if the kNRMA_REPORT_MAX_TRANSACTION_COUNT is missing
}

// Test what happens if any value is missing from passed dictionary

NRMAHarvesterConfiguration* config = [[NRMAHarvesterConfiguration alloc] initWithDictionary:[NSDictionary dictionary]];
XCTAssertEqual(NRMA_DEFAULT_REPORT_PERIOD, config.data_report_period, @"A bad dictionary should parse default report period to its default.");
// if kNRMA_COLLECT_NETWORK_ERRORS is missing.
XCTAssertEqual(true, config.collect_network_errors, @"A bad dictionary should parse default report period to its default.");
// if kNRMA_ERROR_LIMIT is missing
XCTAssertEqual(NRMA_DEFAULT_ERROR_LIMIT, config.error_limit, @"A bad dictionary should parse default error limit to its default.");
// if kNRMA_REPORT_MAX_TRANSACTION_AGE is missing
XCTAssertEqual(NRMA_DEFAULT_MAX_TRANSACTION_AGE, config.report_max_transaction_age, @"A bad dictionary should parse default max transaction aget limit to its default.");
// if kNRMA_REPORT_MAX_TRANSACTION_COUNT is missing
XCTAssertEqual(NRMA_DEFAULT_MAX_TRANSACTION_COUNT, config.report_max_transaction_count, @"A bad dictionary should parse max transactions to its default.");
// if kNRMA_RESPONSE_BODY_LIMIT is missing
XCTAssertEqual(NRMA_DEFAULT_RESPONSE_BODY_LIMIT, config.response_body_limit, @"A bad dictionary should parse response body limit to its default.");
// if kNRMA_STACK_TRACE_LIMIT is missing
XCTAssertEqual(NRMA_DEFAULT_STACK_TRACE_LIMIT, config.stack_trace_limit, @"A bad dictionary should parse response body limit to its default.");
// if kNRMA_AT_MAX_SIZE is missing
XCTAssertEqual(NRMA_DEFAULT_ACTIVITY_TRACE_MAX_SIZE, config.activity_trace_max_size, @"A bad dictionary should parse activity trace max size limit to its default.");
}

- (void) testActivityTraceConfiguration
{
Expand Down

0 comments on commit 64f2013

Please sign in to comment.