Skip to content

Commit

Permalink
Add test for the wingman url input
Browse files Browse the repository at this point in the history
  • Loading branch information
harveysmurf committed Aug 7, 2024
1 parent 8fac635 commit 41c2e11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22002,10 +22002,12 @@ var core = __toESM(require_core());
var import_http_client = __toESM(require_lib());
var import_auth = __toESM(require_auth());
var FLYCI_URL = "https://api.flyci.net";
var WINGMAN_URL = "https://wingman.flyci.net";
var getFlyCIUrl = (path = "") => {
const url = core.getInput("flyci-url") || FLYCI_URL;
return `${url}${path}`;
};
var getWingmanUrl = () => core.getInput("wingman-url") || WINGMAN_URL;
var getOidcToken = () => core.getIDToken(getFlyCIUrl());
var getAccessToken = async () => {
const oidcToken = await getOidcToken();
Expand Down Expand Up @@ -22051,7 +22053,7 @@ var WingmanClient = class _WingmanClient {
run = async () => {
const env = {
...process.env,
LLM_SERVER_URL: getFlyCIUrl(),
LLM_SERVER_URL: getWingmanUrl(),
LLM_API_KEY: this.accessToken,
FLYCI_WINGMAN_OUTPUT_FILE: import_node_path.default.join(getTempDir(), "wingman.json")
};
Expand Down
19 changes: 19 additions & 0 deletions src/__tests__/wingman.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jest.mock("node:fs/promises");
jest.mock("node:os");

describe("WingmanClient", () => {
const wingmanUrlEnv = "INPUT_WINGMAN_URL";
const tmpPath = "/tmp/path";
const path = "/path/to/wingman";
const accessToken = "secret-access-token";
Expand Down Expand Up @@ -66,6 +67,9 @@ describe("WingmanClient", () => {
});

describe("run", () => {
afterEach(() => {
delete process.env[wingmanUrlEnv];
});
it("when wingman execution exits with non-zero exit code should throw error", async () => {
mockExec.mockResolvedValueOnce(1);

Expand All @@ -82,6 +86,21 @@ describe("WingmanClient", () => {
});
});

it("when wingman url input is set should use it", async () => {
process.env[wingmanUrlEnv] = "mock-url";
mockExec.mockResolvedValueOnce(0);

const wingman = await downloadWingman();

await wingman.run();

expect(exec).toHaveBeenCalledExactlyOnceWith(path, [], {
env: expect.objectContaining({
LLM_SERVER_URL: "mock-url",
}),
});
});

it("when wingman execution exits with 0 exit code should return the output file path", async () => {
mockExec.mockResolvedValueOnce(0);

Expand Down

0 comments on commit 41c2e11

Please sign in to comment.