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
|
|
@ -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