|
| 1 | +import { mkdir, rm, writeFile } from "fs/promises"; |
| 2 | +import { join } from "path"; |
| 3 | +import { tmpdir } from "os"; |
1 | 4 | import { vi } from "vitest"; |
2 | 5 | import { http, HttpResponse } from "msw"; |
3 | 6 | import { setupServer } from "msw/node"; |
@@ -48,4 +51,35 @@ describe("compute-next-version integration", () => { |
48 | 51 | expect(core.setOutput).toHaveBeenCalledWith("version-type", expect.any(String)); |
49 | 52 | expect(core.setFailed).not.toHaveBeenCalled(); |
50 | 53 | }); |
| 54 | + |
| 55 | + it("reads generations from the filesystem when projectsApiBase is a path", async () => { |
| 56 | + const dir = await mkdir(join(tmpdir(), "spring-test"), { recursive: true }); |
| 57 | + const apiBase = join(tmpdir(), "spring-test"); |
| 58 | + await mkdir(join(apiBase, "projects", "spring-boot"), { recursive: true }); |
| 59 | + await writeFile( |
| 60 | + join(apiBase, "projects", "spring-boot", "generations.json"), |
| 61 | + JSON.stringify({ |
| 62 | + generations: [ |
| 63 | + { name: "1.0", ossSupportEndDate: "2028-01", commercialSupportEndDate: "2031-01" }, |
| 64 | + ], |
| 65 | + }), |
| 66 | + ); |
| 67 | + |
| 68 | + try { |
| 69 | + await run({ |
| 70 | + version: "1.0.0", |
| 71 | + token: "test-token", |
| 72 | + repository: "owner/repo", |
| 73 | + projectSlug: "spring-boot", |
| 74 | + projectsApiBase: apiBase, |
| 75 | + }); |
| 76 | + |
| 77 | + expect(core.setOutput).toHaveBeenCalledWith("version", expect.any(String)); |
| 78 | + expect(core.setOutput).toHaveBeenCalledWith("version-date", expect.any(String)); |
| 79 | + expect(core.setOutput).toHaveBeenCalledWith("version-type", expect.any(String)); |
| 80 | + expect(core.setFailed).not.toHaveBeenCalled(); |
| 81 | + } finally { |
| 82 | + await rm(apiBase, { recursive: true }); |
| 83 | + } |
| 84 | + }); |
51 | 85 | }); |
0 commit comments