CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
ai-build-seed.test.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| cde9983 | 1 | /** |
| 2 | * Tests for the ai:build seed-issue feature. | |
| 3 | * | |
| 4 | * ensureAiBuildSeedIssue is fire-and-forget — it must never throw even when | |
| 5 | * the DB is unavailable or returns unexpected data. These tests verify the | |
| 6 | * contract without mocks or a live database connection. | |
| 7 | */ | |
| 8 | ||
| 9 | import { describe, it, expect } from "bun:test"; | |
| 10 | import { ensureAiBuildSeedIssue } from "../lib/repo-bootstrap"; | |
| 11 | ||
| 12 | describe("ensureAiBuildSeedIssue", () => { | |
| 13 | it("is exported from repo-bootstrap", () => { | |
| 14 | expect(typeof ensureAiBuildSeedIssue).toBe("function"); | |
| 15 | }); | |
| 16 | ||
| 17 | it("returns a Promise", () => { | |
| 18 | const result = ensureAiBuildSeedIssue( | |
| 19 | "00000000-0000-0000-0000-000000000001", | |
| 20 | "00000000-0000-0000-0000-000000000002" | |
| 21 | ); | |
| 22 | expect(result).toBeInstanceOf(Promise); | |
| 23 | // Swallow the expected DB error — the important thing is it doesn't throw. | |
| 24 | return result.catch(() => {}); | |
| 25 | }); | |
| 26 | ||
| 27 | it("resolves without throwing when DB is unavailable", async () => { | |
| 28 | // The function must catch all DB errors internally and return void. | |
| 29 | await expect( | |
| 30 | ensureAiBuildSeedIssue( | |
| 31 | "00000000-0000-0000-0000-000000000001", | |
| 32 | "00000000-0000-0000-0000-000000000002" | |
| 33 | ) | |
| 34 | ).resolves.toBeUndefined(); | |
| 35 | }); | |
| 36 | ||
| 37 | it("resolves without throwing for a second call with the same fake IDs", async () => { | |
| 38 | // Idempotency check — calling twice on the same IDs should not throw. | |
| 39 | await expect( | |
| 40 | ensureAiBuildSeedIssue( | |
| 41 | "00000000-0000-0000-0000-000000000003", | |
| 42 | "00000000-0000-0000-0000-000000000004" | |
| 43 | ) | |
| 44 | ).resolves.toBeUndefined(); | |
| 45 | }); | |
| 46 | }); |