Skip to content
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

feat(cts): add algoliasearch-lite #436

Merged
merged 10 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,20 @@ public Map<String, Object> postProcessSupportingFileData(
language
);

for (Entry<String, Request[]> entry : cts.entrySet()) {
for (Entry<String, CodegenOperation> entry : operations.entrySet()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no sorting of operations ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's what's missing I forgot!!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouhou it works b3a3600

String operationId = entry.getKey();
if (!operations.containsKey(operationId)) {
if (!cts.containsKey(operationId)) {
throw new CTSException(
"operationId " + operationId + " does not exist in the spec"
);
}
CodegenOperation op = operations.get(operationId);
Request[] op = cts.get(operationId);

List<Object> tests = new ArrayList<>();
for (int i = 0; i < entry.getValue().length; i++) {
for (int i = 0; i < op.length; i++) {
Map<String, Object> test = paramsType.buildJSONForRequest(
entry.getValue()[i],
op,
op[i],
entry.getValue(),
i
);
tests.add(test);
Expand Down Expand Up @@ -190,7 +190,18 @@ public Map<String, Object> postProcessSupportingFileData(
private Map<String, Request[]> loadCTS()
throws JsonParseException, JsonMappingException, IOException, CTSException {
TreeMap<String, Request[]> cts = new TreeMap<>();
File dir = new File("tests/CTS/methods/requests/" + client);
String clientName = client;

// This special case allow us to read the `search` CTS to generated the
// tests for the `algoliasearch-lite` client, which is only available
// in JavaScript
if (
language.equals("javascript") && clientName.equals("algoliasearch-lite")
) {
clientName = "search";
}

File dir = new File("tests/CTS/methods/requests/" + clientName);
File commonTestDir = new File("tests/CTS/methods/requests/common");
if (!dir.exists()) {
throw new CTSException("CTS not found at " + dir.getAbsolutePath(), true);
Expand Down
37 changes: 37 additions & 0 deletions tests/CTS/methods/requests/search/multipleQueries.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
[
{
"method": "multipleQueries",
"testName": "multipleQueries for a single request with minimal parameters",
"parameters": {
"requests": [
{
"indexName": "theIndexName"
}
],
"strategy": "stopIfEnoughMatches"
},
"request": {
"path": "/1/indexes/*/queries",
"method": "POST",
"data": {
"requests": [
{
"indexName": "theIndexName"
}
],
"strategy": "stopIfEnoughMatches"
}
}
},
{
"method": "multipleQueries",
"testName": "multipleQueries for multiple requests with all parameters",
"parameters": {
"requests": [
{
Expand All @@ -9,6 +34,12 @@
"type": "facet",
"facet": "theFacet",
"params": "testParam"
},
{
"indexName": "theIndexName",
"query": "test",
"type": "default",
"params": "testParam"
}
],
"strategy": "stopIfEnoughMatches"
Expand All @@ -24,6 +55,12 @@
"type": "facet",
"facet": "theFacet",
"params": "testParam"
},
{
"indexName": "theIndexName",
"query": "test",
"type": "default",
"params": "testParam"
}
],
"strategy": "stopIfEnoughMatches"
Expand Down
Loading