Source HTTP API ID path patterns (#26623)
This commit is contained in:
parent
2f11c9f7ed
commit
67b9c9c027
25 changed files with 127 additions and 90 deletions
|
|
@ -22,8 +22,9 @@ function run<A>(fn: (svc: Project.Interface) => Effect.Effect<A>) {
|
|||
)
|
||||
}
|
||||
|
||||
function uid() {
|
||||
return SessionID.make(crypto.randomUUID())
|
||||
function legacySessionID() {
|
||||
// Global-session migration covers persisted IDs from before prefixed session IDs.
|
||||
return crypto.randomUUID() as SessionID
|
||||
}
|
||||
|
||||
function seed(opts: { id: SessionID; dir: string; project: ProjectID }) {
|
||||
|
|
@ -73,7 +74,7 @@ describe("migrateFromGlobal", () => {
|
|||
expect(pre.id).toBe(ProjectID.global)
|
||||
|
||||
// 2. Seed a session under "global" with matching directory
|
||||
const id = uid()
|
||||
const id = legacySessionID()
|
||||
seed({ id, dir: tmp.path, project: ProjectID.global })
|
||||
|
||||
// 3. Make a commit so the project gets a real ID
|
||||
|
|
@ -100,7 +101,7 @@ describe("migrateFromGlobal", () => {
|
|||
// 3. Seed a session under "global" with matching directory.
|
||||
// This simulates a session created before git init that wasn't
|
||||
// present when the real project row was first created.
|
||||
const id = uid()
|
||||
const id = legacySessionID()
|
||||
seed({ id, dir: tmp.path, project: ProjectID.global })
|
||||
|
||||
// 4. Call fromDirectory again — project row already exists,
|
||||
|
|
@ -121,7 +122,7 @@ describe("migrateFromGlobal", () => {
|
|||
|
||||
// Legacy sessions may lack a directory value.
|
||||
// Without a matching origin directory, they should remain global.
|
||||
const id = uid()
|
||||
const id = legacySessionID()
|
||||
seed({ id, dir: "", project: ProjectID.global })
|
||||
|
||||
await run((svc) => svc.fromDirectory(tmp.path))
|
||||
|
|
@ -139,7 +140,7 @@ describe("migrateFromGlobal", () => {
|
|||
ensureGlobal()
|
||||
|
||||
// Seed a session under "global" but for a DIFFERENT directory
|
||||
const id = uid()
|
||||
const id = legacySessionID()
|
||||
seed({ id, dir: "/some/other/dir", project: ProjectID.global })
|
||||
|
||||
await run((svc) => svc.fromDirectory(tmp.path))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue