Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Jul 10, 2023
1 parent 7be6970 commit 431e871
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 15 deletions.
44 changes: 44 additions & 0 deletions scripts/snippets/generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { buildSpecs } from '../buildSpecs';
import { buildCustomGenerators, CI, run, toAbsolutePath } from '../common';
import { getTestOutputFolder } from '../config';
import { formatter } from '../formatter';
import { generateOpenapitools } from '../pre-gen';
import { createSpinner } from '../spinners';
import type { Generator } from '../types';

async function snippetsGenerate(gen: Generator): Promise<void> {
const spinner = createSpinner(`generating CTS for ${gen.key}`);

await run(
`yarn openapi-generator-cli --custom-generator=generators/build/libs/algolia-java-openapi-generator-1.0.0.jar generate \
-g algolia-snippets -i specs/bundled/${gen.client}.yml --additional-properties="language=${gen.language},client=${gen.client}"`
);
spinner.succeed();
}

export async function snippetsGenerateMany(
generators: Generator[]
): Promise<void> {
if (!CI) {
const clients = [...new Set(generators.map((gen) => gen.client))];
await buildSpecs(clients, 'yml', true);
}

await generateOpenapitools(generators);
await buildCustomGenerators();

for (const gen of generators) {
if (!getTestOutputFolder(gen.language)) {
continue;
}
await snippetsGenerate(gen);
}

const langs = [...new Set(generators.map((gen) => gen.language))];
for (const lang of langs) {
if (!getTestOutputFolder(lang)) {
continue;
}
await formatter(lang, toAbsolutePath(`tests/output/${lang}`));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
{
"testName": "getClusterIncidents",
"parameters": {
"clusters": [
"c1-de"
]
"clusters": "c1-de"
},
"request": {
"path": "/1/incidents/c1-de",
Expand Down
4 changes: 1 addition & 3 deletions tests/CTS/methods/requests/monitoring/getClusterStatus.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
{
"testName": "getClusterStatus",
"parameters": {
"clusters": [
"c1-de"
]
"clusters": "c1-de"
},
"request": {
"path": "/1/status/c1-de",
Expand Down
4 changes: 1 addition & 3 deletions tests/CTS/methods/requests/monitoring/getIndexingTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
{
"testName": "getIndexingTime",
"parameters": {
"clusters": [
"c1-de"
]
"clusters": "c1-de"
},
"request": {
"path": "/1/indexing/c1-de",
Expand Down
4 changes: 1 addition & 3 deletions tests/CTS/methods/requests/monitoring/getLatency.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
{
"testName": "getLatency",
"parameters": {
"clusters": [
"c1-de"
]
"clusters": "c1-de"
},
"request": {
"path": "/1/latency/c1-de",
Expand Down
4 changes: 1 addition & 3 deletions tests/CTS/methods/requests/monitoring/getReachability.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
{
"testName": "getReachability",
"parameters": {
"clusters": [
"c1-de"
]
"clusters": "c1-de"
},
"request": {
"path": "/1/reachability/c1-de/probes",
Expand Down

0 comments on commit 431e871

Please sign in to comment.