Skip to content

Commit

Permalink
Fix location dispatching
Browse files Browse the repository at this point in the history
commit_hash:bc9284b4c05a93210487ea5579037d071f88b8c3
  • Loading branch information
Sergey70 committed Dec 8, 2024
1 parent 26c7c86 commit 42b36a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion AppMetricaCore/Sources/Location/AMALocationDispatcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ - (void)cancelTimer

- (void)processRequest:(AMALocationRequest *)request
{
AMAArrayIterator *hostsProvider = [[AMAArrayIterator alloc] initWithArray:self.configuration.hosts];
NSArray *hosts = self.configuration.hosts;
if (hosts.count == 0) {
AMALogError(@"Unable to retrieve host for location request");
return;
}

AMAArrayIterator *hostsProvider = [[AMAArrayIterator alloc] initWithArray:hosts];

if (request == nil) {
NSError *internalError = [AMAErrorsFactory internalInconsistencyError:@"Failed to process location request"];
Expand Down
6 changes: 6 additions & 0 deletions AppMetricaCore/Tests/AMALocationDispatcherTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@
[[executor should] receive:@selector(executeAfterDelay:block:)];
[dispatcher handleVisitAdd];
});

it(@"Should not process request if no hosts are provided", ^{
[configuration stub:@selector(hosts) andReturn:@[]];
[[requestProcessor shouldNot] receive:@selector(processWithCallback:)];
[dispatcher handleVisitAdd];
});

context(@"Callback location", ^{
beforeEach(^{
Expand Down

0 comments on commit 42b36a8

Please sign in to comment.