|
| 1 | +import fs from "fs" |
| 2 | +import path from "path" |
| 3 | +import { fileURLToPath } from "url" |
| 4 | + |
| 5 | +const __filename = fileURLToPath(import.meta.url) |
| 6 | +const __dirname = path.dirname(__filename) |
| 7 | +const repoRoot = path.resolve(__dirname, "..") |
| 8 | + |
| 9 | +describe("Shared OpenAPI artifact sync scaffolding", () => { |
| 10 | + it("verifies provider and target artifact files contain valid OpenAPI structure", () => { |
| 11 | + const providerArtifactPath = path.join(repoRoot, "openapi/components/rerum-shared-components.openapi.yaml") |
| 12 | + const targetArtifactPath = path.join(repoRoot, "schemas/openapi/rerum-shared-components.openapi.yaml") |
| 13 | + const providerArtifact = fs.readFileSync(providerArtifactPath, "utf8") |
| 14 | + const targetArtifact = fs.readFileSync(targetArtifactPath, "utf8") |
| 15 | + |
| 16 | + for (const artifact of [providerArtifact, targetArtifact]) { |
| 17 | + expect(artifact).toContain("openapi: 3.0.3") |
| 18 | + expect(artifact).toContain("title: RERUM Shared Components") |
| 19 | + expect(artifact).toContain("version: 0.1.0") |
| 20 | + expect(artifact).toContain("components:") |
| 21 | + expect(artifact).toContain("schemas: {}") |
| 22 | + } |
| 23 | + }) |
| 24 | + |
| 25 | + it("verifies the shared artifact sync workflow configuration", () => { |
| 26 | + const workflowPath = path.join(repoRoot, ".github/workflows/sync-rerum-shared-openapi.yml") |
| 27 | + const workflow = fs.readFileSync(workflowPath, "utf8") |
| 28 | + |
| 29 | + expect(workflow).toContain("openapi/components/rerum-shared-components.openapi.yaml") |
| 30 | + expect(workflow).toContain("sync-provider-artifact.yml") |
| 31 | + expect(workflow).toContain("repo: 'rerum_openapi'") |
| 32 | + expect(workflow).toContain("target_artifact_path: 'schemas/openapi/rerum-shared-components.openapi.yaml'") |
| 33 | + }) |
| 34 | +}) |
0 commit comments