mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-09 22:58:28 +00:00
test(core): simplify repository cache layer wiring
This commit is contained in:
parent
d3bbfff826
commit
80af18d24a
2 changed files with 11 additions and 12 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import path from "path"
|
||||
import { Context, Effect, Layer, Schema } from "effect"
|
||||
import { LayerNode } from "./effect/layer-node"
|
||||
import { FSUtil } from "./fs-util"
|
||||
import { Git } from "./git"
|
||||
import { Global } from "./global"
|
||||
|
|
@ -258,6 +259,7 @@ export const defaultLayer: Layer.Layer<Service> = layer.pipe(
|
|||
Layer.provide(Git.defaultLayer),
|
||||
Layer.provide(Global.defaultLayer),
|
||||
)
|
||||
export const node = LayerNode.make(layer, [FSUtil.node, Git.node, EffectFlock.node, Global.node])
|
||||
|
||||
function statusForRepository(input: { reuse: boolean; refresh?: boolean; branchMatches?: boolean }) {
|
||||
if (!input.reuse) return "cloned" as const
|
||||
|
|
|
|||
|
|
@ -3,12 +3,10 @@ import fs from "fs/promises"
|
|||
import path from "path"
|
||||
import { pathToFileURL } from "url"
|
||||
import { Effect, Layer } from "effect"
|
||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||
import { Git } from "@opencode-ai/core/git"
|
||||
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
||||
import { Global } from "@opencode-ai/core/global"
|
||||
import { Repository } from "@opencode-ai/core/repository"
|
||||
import { RepositoryCache } from "@opencode-ai/core/repository-cache"
|
||||
import { EffectFlock } from "@opencode-ai/core/util/effect-flock"
|
||||
import { git, gitRemote } from "./fixture/git"
|
||||
import { tmpdir } from "./fixture/tmpdir"
|
||||
import { testEffect } from "./lib/effect"
|
||||
|
|
@ -89,15 +87,14 @@ describe("RepositoryCache", () => {
|
|||
})
|
||||
|
||||
function cacheLayer(root: string) {
|
||||
const dependencies = Layer.mergeAll(
|
||||
Global.layerWith({ state: path.join(root, "state"), repos: path.join(root, "repos") }),
|
||||
FSUtil.defaultLayer,
|
||||
)
|
||||
return RepositoryCache.layer.pipe(
|
||||
Layer.provide(EffectFlock.layer.pipe(Layer.provide(dependencies))),
|
||||
Layer.provide(Git.defaultLayer),
|
||||
Layer.provide(dependencies),
|
||||
)
|
||||
return LayerNode.buildLayer(RepositoryCache.node, {
|
||||
replacements: [
|
||||
LayerNode.replace(
|
||||
Global.node,
|
||||
Global.layerWith({ state: path.join(root, "state"), repos: path.join(root, "repos") }),
|
||||
),
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
function withRemote<A, E, R>(body: (fixture: Awaited<ReturnType<typeof gitRemote>>) => Effect.Effect<A, E, R>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue