feat(id): brand ProjectID through Drizzle and Zod schemas (#16948)

This commit is contained in:
Kit Langton
2026-03-11 16:44:26 -04:00
committed by GitHub
parent c37f7b9d99
commit dbc00aa8e0
15 changed files with 77 additions and 44 deletions

View File

@@ -6,6 +6,7 @@ import path from "path"
import { tmpdir } from "../fixture/fixture"
import { Filesystem } from "../../src/util/filesystem"
import { GlobalBus } from "../../src/bus/global"
import { ProjectID } from "../../src/project/schema"
Log.init({ print: false })
@@ -74,7 +75,7 @@ describe("Project.fromDirectory", () => {
const { project } = await p.fromDirectory(tmp.path)
expect(project).toBeDefined()
expect(project.id).toBe("global")
expect(project.id).toBe(ProjectID.global)
expect(project.vcs).toBe("git")
expect(project.worktree).toBe(tmp.path)
@@ -90,7 +91,7 @@ describe("Project.fromDirectory", () => {
const { project } = await p.fromDirectory(tmp.path)
expect(project).toBeDefined()
expect(project.id).not.toBe("global")
expect(project.id).not.toBe(ProjectID.global)
expect(project.vcs).toBe("git")
expect(project.worktree).toBe(tmp.path)
@@ -107,7 +108,7 @@ describe("Project.fromDirectory", () => {
await withMode("rev-list-fail", async () => {
const { project } = await p.fromDirectory(tmp.path)
expect(project.vcs).toBe("git")
expect(project.id).toBe("global")
expect(project.id).toBe(ProjectID.global)
expect(project.worktree).toBe(tmp.path)
})
})
@@ -301,7 +302,7 @@ describe("Project.update", () => {
await expect(
Project.update({
projectID: "nonexistent-project-id",
projectID: ProjectID.make("nonexistent-project-id"),
name: "Should Fail",
}),
).rejects.toThrow("Project not found: nonexistent-project-id")