-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'alloy-avoid-parent-calls' into staging
- Loading branch information
Showing
8 changed files
with
255 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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 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 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,64 @@ | ||
package Integrations::AlloyV2::Dummy; | ||
use Moo; | ||
|
||
extends 'Integrations::AlloyV2'; | ||
sub _build_config_file { path(__FILE__)->sibling("alloyv2.yml")->stringify } | ||
|
||
package main; | ||
|
||
use strict; | ||
use warnings; | ||
use utf8; | ||
|
||
use Test::More; | ||
use Test::MockModule; | ||
use Encode; | ||
use JSON::MaybeXS; | ||
use Path::Tiny; | ||
|
||
my $integration = Integrations::AlloyV2::Dummy->new; | ||
my $mocked_integration = Test::MockModule->new('Integrations::AlloyV2'); | ||
$mocked_integration->mock('api_call', sub { | ||
my ($self, %args) = @_; | ||
my $call = $args{call}; | ||
if ($call =~ 'aqs/join') { | ||
return decode_json(encode_utf8(path(__FILE__)->sibling('json/alloyv2/join_response.json')->slurp)); | ||
} | ||
fail "Got unexpected call: $call"; | ||
}); | ||
|
||
subtest "Join results are parsed correctly" => sub { | ||
my $query = { | ||
properties => { | ||
joinAttributes => [ 'root^parent_attribute.child_attribute' ] | ||
} | ||
}; | ||
my $res = $integration->search($query, 1); | ||
is_deeply $res, [ | ||
{ | ||
'attributes' => [ | ||
{ | ||
'attributeCode' => 'normal_attribute', | ||
'value' => 'n1' | ||
}, | ||
{ | ||
'attributeCode' => 'root.parent_attribute.child_attribute', | ||
'value' => 'c1' | ||
} | ||
], | ||
'itemId' => 'r1', | ||
'joinedItemIDs' => ['p1'] | ||
}, | ||
{ | ||
'itemId' => 'r2', | ||
'attributes' => [ | ||
{ | ||
'value' => 'n2', | ||
'attributeCode' => 'normal_attribute' | ||
} | ||
] | ||
} | ||
]; | ||
}; | ||
|
||
done_testing; |
This file contains 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,6 @@ | ||
{ | ||
"api_key": "api_key", | ||
"api_url": "http://localhost/api/", | ||
"rfs_design": 'rfs_design', | ||
"parent_attribute_name": "parent_attribute_name" | ||
} |
This file contains 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,43 @@ | ||
{ | ||
"joinResults": [ | ||
{ | ||
"itemId": "r1", | ||
"joinQueries": [ | ||
{ | ||
"item": { | ||
"itemId": "p1", | ||
"attributes": [ | ||
{ | ||
"attributeCode": "child_attribute", | ||
"value": "c1" | ||
} | ||
] | ||
}, | ||
"joinAttributes": [ | ||
"root.parent_attribute.child_attribute" | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"results": [ | ||
{ | ||
"itemId": "r1", | ||
"attributes": [ | ||
{ | ||
"attributeCode": "normal_attribute", | ||
"value": "n1" | ||
} | ||
] | ||
}, | ||
{ | ||
"itemId": "r2", | ||
"attributes": [ | ||
{ | ||
"attributeCode": "normal_attribute", | ||
"value": "n2" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains 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 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 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