Skip to content

Commit 213fd26

Browse files
chore: generated code for commit ff02ba0. [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent ff02ba0 commit 213fd26

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

clients/algoliasearch-client-javascript/packages/predict/src/predictClient.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,11 @@ export function createPredictClient({
5050
const transporter = createTransporter({
5151
hosts: getDefaultHosts(regionOption),
5252
...options,
53-
algoliaAgent: {
54-
...getAlgoliaAgent({
55-
algoliaAgents,
56-
client: 'Predict',
57-
version: apiClientVersion,
58-
}),
59-
value: '',
60-
},
53+
algoliaAgent: getAlgoliaAgent({
54+
algoliaAgents,
55+
client: 'Predict',
56+
version: apiClientVersion,
57+
}),
6158
baseHeaders: {
6259
'content-type': 'text/plain',
6360
...auth.headers(),

tests/output/java/src/test/java/com/algolia/client/Predict.test.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertThrows;
5+
import static org.junit.jupiter.api.Assertions.assertTrue;
56

67
import com.algolia.EchoInterceptor;
78
import com.algolia.EchoResponse;
@@ -33,12 +34,35 @@ PredictClient createClient() {
3334
}
3435

3536
@Test
36-
@DisplayName("calls api with default read timeouts")
37+
@DisplayName("calls api with correct user agent")
3738
void commonApiTest0() {
3839
PredictClient $client = createClient();
3940

4041
String path0 = "/test";
4142

43+
$client.post(path0);
44+
EchoResponse result = echo.getLastResponse();
45+
46+
{
47+
String regexp =
48+
"^Algolia for Java \\(\\d+\\.\\d+\\.\\d+(-.*)?\\)(; [a-zA-Z. ]+" +
49+
" (\\(\\d+((\\.\\d+)?\\.\\d+)?(-.*)?\\))?)*(; Predict" +
50+
" (\\(\\d+\\.\\d+\\.\\d+(-.*)?\\)))(; [a-zA-Z. ]+" +
51+
" (\\(\\d+((\\.\\d+)?\\.\\d+)?(-.*)?\\))?)*$";
52+
assertTrue(
53+
result.headers.get("user-agent").matches(regexp),
54+
"Expected " + result.headers.get("user-agent") + " to match the following regex: " + regexp
55+
);
56+
}
57+
}
58+
59+
@Test
60+
@DisplayName("calls api with default read timeouts")
61+
void commonApiTest1() {
62+
PredictClient $client = createClient();
63+
64+
String path0 = "/test";
65+
4266
$client.get(path0);
4367
EchoResponse result = echo.getLastResponse();
4468

@@ -48,7 +72,7 @@ void commonApiTest0() {
4872

4973
@Test
5074
@DisplayName("calls api with default write timeouts")
51-
void commonApiTest1() {
75+
void commonApiTest2() {
5276
PredictClient $client = createClient();
5377

5478
String path0 = "/test";

tests/output/javascript/src/client/predict.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ function createClient(): PredictClient {
1313
}
1414

1515
describe('commonApi', () => {
16+
test('calls api with correct user agent', async () => {
17+
const $client = createClient();
18+
19+
const result = (await $client.post({
20+
path: '/test',
21+
})) as unknown as EchoResponse;
22+
23+
expect(decodeURI(result.algoliaAgent)).toMatch(
24+
/^Algolia for JavaScript \(\d+\.\d+\.\d+(-.*)?\)(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-.*)?\))?)*(; Predict (\(\d+\.\d+\.\d+(-.*)?\)))(; [a-zA-Z. ]+ (\(\d+((\.\d+)?\.\d+)?(-.*)?\))?)*$/
25+
);
26+
});
27+
1628
test('calls api with default read timeouts', async () => {
1729
const $client = createClient();
1830

0 commit comments

Comments
 (0)