Files
opencode/packages/core/test/location.test.ts
+21 8c94e9005f chore: merge dev into v2 (#34788)
Co-authored-by: Brendan Allan <[email protected]>
Co-authored-by: Kit Langton <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: Affan Ali <[email protected]>
Co-authored-by: affanali2k3 <[email protected]>
Co-authored-by: Frank <[email protected]>
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴 <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
Co-authored-by: Jay V <[email protected]>
Co-authored-by: Dax Raad <[email protected]>
Co-authored-by: Aarav Sareen <[email protected]>
Co-authored-by: OpeOginni <[email protected]>
Co-authored-by: Luke Parker <[email protected]>
Co-authored-by: Ben Guthrie <[email protected]>
Co-authored-by: Dax <[email protected]>
Co-authored-by: Filip <[email protected]>
Co-authored-by: Max Anderson <[email protected]>
Co-authored-by: Brendan Allan <[email protected]>
Co-authored-by: Jack <[email protected]>
Co-authored-by: Shoubhit Dash <[email protected]>
Co-authored-by: Dustin Deus <[email protected]>
Co-authored-by: starptech <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
Co-authored-by: usrnk1 <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: runvip <[email protected]>
Co-authored-by: opencode <[email protected]>
Co-authored-by: Julian Coy <[email protected]>
Co-authored-by: Vladimir Glafirov <[email protected]>
2026-07-01 17:12:00 -04:00

43 lines
1.6 KiB
TypeScript

import { describe, expect } from "bun:test"
import { Effect, Layer } from "effect"
import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
import { Location } from "@opencode-ai/core/location"
import { Project } from "@opencode-ai/core/project"
import { AbsolutePath } from "@opencode-ai/core/schema"
import { WorkspaceV2 } from "@opencode-ai/core/workspace"
import { testEffect } from "./lib/effect"
const workspaceID = WorkspaceV2.ID.make("wrk_test")
const ref = { directory: AbsolutePath.make("/repo/packages/app"), workspaceID }
const projectLayer = Layer.succeed(
Project.Service,
Project.Service.of({
directories: () => Effect.succeed([]),
resolve: () =>
Effect.succeed({
id: Project.ID.make("project"),
directory: AbsolutePath.make("/repo"),
vcs: { type: "git", store: AbsolutePath.make("/repo/.git") },
}),
commit: () => Effect.void,
}),
)
const it = testEffect(AppNodeBuilder.build(Location.boundNode(ref), [[Project.node, projectLayer]]))
describe("Location", () => {
it.effect("resolves the current project and vcs information", () =>
Effect.gen(function* () {
const location = yield* Location.Service
expect(location.directory).toBe(AbsolutePath.make("/repo/packages/app"))
expect(location.workspaceID).toBe(workspaceID)
expect(location.project.id).toBe(Project.ID.make("project"))
expect(location.project.directory).toBe(AbsolutePath.make("/repo"))
expect(location.vcs).toEqual({
type: "git",
store: AbsolutePath.make("/repo/.git"),
})
}),
)
})