Skip to content

Commit 198ca8a

Browse files
committed
omg
1 parent 119a770 commit 198ca8a

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

scripts/cts/testServer/algoliaMock.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ function addRoutes(app: Express): void {
3838
});
3939
});
4040

41+
// languages that just put the response in a map, there is no strict parsing or types to match.
42+
const isLaxLanguage = (lang: string) => {
43+
return lang === 'dart' || lang === 'javascript' || lang === 'python' || lang === 'php';
44+
};
45+
4146
app.get('/1/indexes/:indexName/settings', (req, res) => {
4247
const lang = req.params.indexName.match(/^cts_e2e_unknownField_(.*)$/)?.[1] as string;
4348
let unknown = {};
44-
if (lang !== 'javascript' && lang !== 'python') {
45-
// js and python just put the response in a map, there is no strict parsing.
49+
if (!isLaxLanguage(lang)) {
4650
unknown = {
4751
unknownFieldNameThatWillNeverBeAddedToTheSpecIHope: 'hello',
4852
};
@@ -59,7 +63,7 @@ function addRoutes(app: Express): void {
5963
app.get('/1/indexes/:indexName/rules/:objectID', (req, res) => {
6064
const lang = req.params.indexName.match(/^cts_e2e_unknownFieldNested_(.*)$/)?.[1] as string;
6165
let unknown = {};
62-
if (lang !== 'javascript' && lang !== 'python') {
66+
if (!isLaxLanguage(lang)) {
6367
unknown = {
6468
unknownFieldNameThatWillNeverBeAddedToTheSpecIHope: 'hello',
6569
};

templates/kotlin/tests/client/tests.mustache

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fun `{{#lambda.replaceBacktick}}{{{testName}}}{{/lambda.replaceBacktick}}`() = r
3737
assertEquals({{#match}}{{> tests/param_value}}{{/match}}, it.url.host);
3838
{{/testHost}}
3939
}{{/testResponse}}{{#testResponse}}
40-
{{#isHelper}}response = {
40+
response = {
4141
{{^match.isPrimitive}}
4242
assertNotNull(it)
4343
JSONAssert.assertEquals("""{{{match.value}}}""", Json.encodeToString(Json.encodeToJsonElement(it)), JSONCompareMode.STRICT)
@@ -50,11 +50,7 @@ fun `{{#lambda.replaceBacktick}}{{{testName}}}{{/lambda.replaceBacktick}}`() = r
5050
assertEquals({{#match}}{{> tests/param_value}}{{/match}}, it)
5151
{{/match.isNull}}
5252
{{/match.isPrimitive}}
53-
}{{/isHelper}}
54-
{{^isHelper}}response = {
55-
val response = Json.encodeToString(it)
56-
assertEquals({{#match}}{{> tests/param_value}}{{/match}}, response)
57-
}{{/isHelper}}
53+
}
5854
{{/testResponse}}
5955
)
6056
{{/isMethod}}
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
{{#hasResponse}}let response{{#isGeneric}}: Response<{{#lambda.prefix}}{{{returnType}}}{{/lambda.prefix}}<{{#lambda.prefix}}Hit{{/lambda.prefix}}>>{{/isGeneric}} = {{> tests/method}}{{/hasResponse}}
2-
{{^hasResponse}}let _{{#isGeneric}}: Response<{{#lambda.prefix}}{{{returnType}}}{{/lambda.prefix}}<{{#lambda.prefix}}Hit{{/lambda.prefix}}>>{{/isGeneric}} = {{> tests/method}}{{/hasResponse}}
1+
{{#hasResponse}}let response{{#isGeneric}}: {{#useEchoRequester}}Response<{{/useEchoRequester}}{{#lambda.prefix}}{{{returnType}}}{{/lambda.prefix}}<{{#lambda.prefix}}Hit{{/lambda.prefix}}>{{#useEchoRequester}}>{{/useEchoRequester}}{{/isGeneric}} = {{> tests/method}}{{/hasResponse}}
2+
{{^hasResponse}}let _ = {{> tests/method}}{{/hasResponse}}
33
{{^isHelper}}
44
{{^isBenchmark}}
5-
let responseBodyData = try XCTUnwrap(response.bodyData)
65
{{#useEchoRequester}}
7-
let echoResponse = try CodableHelper.jsonDecoder.decode(EchoResponse.self, from: responseBodyData)
8-
{{/useEchoRequester}}
9-
{{^useEchoRequester}}
10-
let responseBodyJSON = try XCTUnwrap(responseBodyData.jsonString)
6+
let echoResponse = try CodableHelper.jsonDecoder.decode(EchoResponse.self, from: XCTUnwrap(response.bodyData))
117
{{/useEchoRequester}}
128
{{/isBenchmark}}
139
{{/isHelper}}

templates/swift/tests/client/tests.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
{{^isHelper}}
5757
let comparableData = "{{#lambda.escapeQuotes}}{{{match.value}}}{{/lambda.escapeQuotes}}".data(using: .utf8)
5858
let comparableJSON = try XCTUnwrap(comparableData?.jsonString)
59-
XCTAssertEqual(comparableJSON, responseBodyJSON);
59+
XCTAssertEqual(comparableJSON, String(data: try CodableHelper.jsonEncoder.encode(response), encoding: .utf8)!);
6060
{{/isHelper}}
6161
{{/testResponse}}
6262
{{#shouldScope}}

templates/swift/tests/method.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
try {{#isAsyncMethod}}await {{/isAsyncMethod}}client.{{method}}{{^isHelper}}{{^isGuide}}WithHTTPInfo{{/isGuide}}{{/isHelper}}({{#hasParams}}{{#parametersWithDataType}}{{> tests/generateParams }}{{^-last}}, {{/-last}}{{/parametersWithDataType}}{{/hasParams}}{{#hasRequestOptions}}{{#requestOptions}}, requestOptions: RequestOptions(
1+
try {{#isAsyncMethod}}await {{/isAsyncMethod}}client.{{method}}{{#useEchoRequester}}WithHTTPInfo{{/useEchoRequester}}({{#hasParams}}{{#parametersWithDataType}}{{> tests/generateParams }}{{^-last}}, {{/-last}}{{/parametersWithDataType}}{{/hasParams}}{{#hasRequestOptions}}{{#requestOptions}}, requestOptions: RequestOptions(
22
{{#headers}}
33
headers: [{{#parametersWithDataType}}"{{key}}": {{> tests/paramValue }}{{^-last}}, {{/-last}}{{/parametersWithDataType}}]{{#queryParameters}},{{/queryParameters}}
44
{{/headers}}

0 commit comments

Comments
 (0)