Compare commits

..
Author SHA1 Message Date
James Long 6dc02408c9 test(core): simplify location mutation layer wiring 2026-06-20 21:58:11 -04:00
4 changed files with 10 additions and 15 deletions
-2
View File
@@ -2,7 +2,6 @@ export * as CommandV2 from "./command"
import { Context, Effect, Layer, Schema } from "effect"
import { castDraft, type Draft } from "immer"
import { LayerNode } from "./effect/layer-node"
import { ModelV2 } from "./model"
import { State } from "./state"
@@ -69,4 +68,3 @@ export const layer = Layer.effect(
)
export const locationLayer = layer
export const node = LayerNode.make(layer, [])
+3
View File
@@ -2,6 +2,7 @@ export * as LocationMutation from "./location-mutation"
import path from "path"
import { Context, Effect, Layer, Schema } from "effect"
import { LayerNode } from "./effect/layer-node"
import { FSUtil } from "./fs-util"
import { Location } from "./location"
@@ -153,3 +154,5 @@ export const layer = Layer.effect(
)
export const locationLayer = layer
export const node = (location: LayerNode.Node<Location.Service>) => LayerNode.make(layer, [FSUtil.node, location])
+2 -3
View File
@@ -1,11 +1,10 @@
import fs from "fs/promises"
import path from "path"
import { describe, expect } from "bun:test"
import { Effect, Schema } from "effect"
import { Effect, Layer, Schema } from "effect"
import { CommandV2 } from "@opencode-ai/core/command"
import { Config } from "@opencode-ai/core/config"
import { ConfigCommandPlugin } from "@opencode-ai/core/config/plugin/command"
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
import { FSUtil } from "@opencode-ai/core/fs-util"
import { ModelV2 } from "@opencode-ai/core/model"
import { ProviderV2 } from "@opencode-ai/core/provider"
@@ -13,7 +12,7 @@ import { AbsolutePath } from "@opencode-ai/core/schema"
import { tmpdir } from "../fixture/tmpdir"
import { testEffect } from "../lib/effect"
const it = testEffect(LayerNode.buildLayer(LayerNode.group([CommandV2.node, FSUtil.node])))
const it = testEffect(Layer.mergeAll(CommandV2.locationLayer, FSUtil.defaultLayer))
const decode = Schema.decodeUnknownSync(Config.Info)
describe("ConfigCommandPlugin.Plugin", () => {
+5 -10
View File
@@ -2,7 +2,7 @@ import fs from "fs/promises"
import path from "path"
import { describe, expect, test } from "bun:test"
import { Effect, Layer, Schema } from "effect"
import { FSUtil } from "@opencode-ai/core/fs-util"
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
import { Location } from "@opencode-ai/core/location"
import { LocationMutation } from "@opencode-ai/core/location-mutation"
import { AbsolutePath } from "@opencode-ai/core/schema"
@@ -11,16 +11,11 @@ import { location } from "./fixture/location"
import { it } from "./lib/effect"
function provide(directory: string) {
return Effect.provide(
LocationMutation.layer.pipe(
Layer.provide(
Layer.mergeAll(
FSUtil.defaultLayer,
Layer.succeed(Location.Service, Location.Service.of(location({ directory: AbsolutePath.make(directory) }))),
),
),
),
const activeLocation = LayerNode.make(
Layer.succeed(Location.Service, Location.Service.of(location({ directory: AbsolutePath.make(directory) }))),
[],
)
return Effect.provide(LayerNode.buildLayer(LocationMutation.node(activeLocation)))
}
function withTmp<A, E, R>(f: (directory: string) => Effect.Effect<A, E, R>) {