Skip to content

Commit

Permalink
954: Adds a sanity check test that the import command can actually im…
Browse files Browse the repository at this point in the history
…port an openAPI spec, and fix a race condition bug arising from it.
  • Loading branch information
wfaithfull committed Mar 4, 2024
1 parent fc03134 commit a6daab6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/breadboard-cli/src/commands/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const importGraph = async (url: string, options: ImportOptions) => {

const board = apiRef;
if (outputPath != undefined) {
outputBoard(board.board.board, api, outputPath);
await outputBoard(board.board.board, api, outputPath);
} else {
console.log(JSON.stringify(board.board.board, null, 2));
}
Expand Down
20 changes: 20 additions & 0 deletions packages/breadboard-cli/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import test from "ava";
import { ExecException, exec } from "child_process";
import * as fs from "fs";
import path from "path";
import { importGraph } from "../src/commands/import.js";

const packageDir = getPackageDir("@google-labs/breadboard-cli");
console.debug("packageDir", packageDir);
Expand Down Expand Up @@ -203,6 +204,25 @@ test.after.always(() => {
fs.rmSync(testDataDir, { recursive: true });
});

test("import can import an openapi spec", async (t) => {
await importGraph("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/3.1.0/examples/v3.0/petstore.yaml", {
api: undefined,
output: testDataDir,
root: "",
save: false,
watch: false
})

const routes: string[] = ["createPets.json", "listPets.json", "showPetById.json"]
.map(f =>
path.resolve(testDataDir, f)
)

routes.forEach(f => {
t.true(fs.existsSync(f))
})
})

//////////////////////////////////////////////////
test("all test files exist", (t) => {
testFiles.forEach((p) => {
Expand Down

0 comments on commit a6daab6

Please sign in to comment.