GeezerVison is showing github.com — test(core): simplify registry regression fixtures · anomalyco/opencode@e43f58d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/core/test/fixture/location.ts +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,14 +14,18 @@ export function location(ref: Location.Ref, input: { projectDirectory?: Absolute | 14 | 14 | } satisfies Location.Interface | 15 | 15 | } | 16 | 16 |
| | 17 | +export function locationLayer(ref: Location.Ref, input: { projectDirectory?: AbsolutePath; vcs?: Project.Vcs } = {}) { | | 18 | + return Layer.succeed(Location.Service, Location.Service.of(location(ref, input))) | | 19 | +} | | 20 | + | 17 | 21 | export const tempLocationLayer = Layer.unwrap( | 18 | 22 | Effect.acquireRelease( | 19 | 23 | Effect.promise(() => tmpdir()), | 20 | 24 | (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()), | 21 | 25 | ).pipe( | 22 | 26 | Effect.map((tmp) => { | 23 | 27 | const ref = Location.Ref.make({ directory: AbsolutePath.make(tmp.path) }) | 24 | | - return Layer.succeed(Location.Service, Location.Service.of(location(ref))) | | 28 | + return locationLayer(ref) | 25 | 29 | }), | 26 | 30 | ), | 27 | 31 | ) |
Collapse file Copy file name to clipboardExpand all lines: packages/core/test/integration-replay.test.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -59,7 +59,7 @@ describe("Integration replay", () => { | 59 | 59 | .complete({ integrationID, attemptID: attempt.attemptID, code: "dummy-code" }) | 60 | 60 | .pipe(Effect.exit) | 61 | 61 |
| 62 | | - expect(Exit.isFailure(exit) && Cause.hasDies(exit.cause)).toBe(true) | | 62 | + expect(exit).toMatchObject(Exit.die(failure)) | 63 | 63 | expect(Exit.isFailure(exit) && Cause.squash(exit.cause)).toBe(failure) | 64 | 64 | expect(yield* integrations.oauth.status({ integrationID, attemptID: attempt.attemptID })).toEqual({ | 65 | 65 | status: "failed", | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/test/mcp.test.ts +12-17Lines changed: 12 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -58,7 +58,7 @@ import { ExitCode, makeHandle, ProcessId } from "effect/unstable/process/ChildPr | 58 | 58 | import { Image } from "@opencode-ai/core/image" | 59 | 59 | import { testEffect } from "./lib/effect" | 60 | 60 | import { imagePassthrough } from "./lib/image" | 61 | | -import { location } from "./fixture/location" | | 61 | +import { location, locationLayer } from "./fixture/location" | 62 | 62 | import { hostEnvironmentLayer, recordingEnvironmentLayer } from "./fixture/environment" | 63 | 63 | import { executeTool, toolDefinitions, toolIdentity, waitForCodeModeTool, waitForTool } from "./lib/tool" | 64 | 64 |
| @@ -1386,22 +1386,17 @@ testEffect(Layer.empty).live("serializes MCP config restoration behind an in-fli | 1386 | 1386 | ) | 1387 | 1387 | }), | 1388 | 1388 | ) | | 1389 | +const shutdownIt = testEffect( | | 1390 | + AppNodeBuilder.build( | | 1391 | + LayerNode.group([Bus.node, Integration.node, Credential.node, Form.node, Environment.node, Location.node]), | | 1392 | + [ | | 1393 | + [Location.node, locationLayer({ directory: AbsolutePath.make(import.meta.dir) })], | | 1394 | + [Environment.node, hostEnvironmentLayer], | | 1395 | + ], | | 1396 | + ), | | 1397 | +) | 1389 | 1398 | ;["active", "queued"].forEach((phase) => | 1390 | | - testEffect( | 1391 | | - AppNodeBuilder.build( | 1392 | | - LayerNode.group([Bus.node, Integration.node, Credential.node, Form.node, Environment.node, Location.node]), | 1393 | | - [ | 1394 | | - [ | 1395 | | - Location.node, | 1396 | | - Layer.succeed( | 1397 | | - Location.Service, | 1398 | | - Location.Service.of(location({ directory: AbsolutePath.make(import.meta.dir) })), | 1399 | | - ), | 1400 | | - ], | 1401 | | - [Environment.node, hostEnvironmentLayer], | 1402 | | - ], | 1403 | | - ), | 1404 | | - ).effect(`discards ${phase} MCP notifications after its layer closes`, () => | | 1399 | + shutdownIt.effect(`discards ${phase} MCP notifications after its layer closes`, () => | 1405 | 1400 | Effect.gen(function* () { | 1406 | 1401 | const bus = yield* Bus.Service | 1407 | 1402 | const entered = yield* Deferred.make<void>() | @@ -1413,7 +1408,7 @@ testEffect(Layer.empty).live("serializes MCP config restoration behind an in-fli | 1413 | 1408 | Effect.andThen(TestClock.adjust("500 millis")), | 1414 | 1409 | ), | 1415 | 1410 | ) | 1416 | | - const context = yield* Layer.build(Mcp.layer()).pipe(Scope.provide(root)) | | 1411 | + const context = yield* Layer.buildWithScope(Mcp.layer(), root) | 1417 | 1412 | const service = Context.get(context, Mcp.Service) | 1418 | 1413 | const observed: string[] = [] | 1419 | 1414 | let block = false | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/test/plugin.test.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,7 +55,7 @@ describe("Plugin", () => { | 55 | 55 | }), | 56 | 56 | ) | 57 | 57 |
| 58 | | - it.effect("refreshes its own stored OAuth connection during plugin activation", () => | | 58 | + it.live("refreshes its own stored OAuth connection during plugin activation", () => | 59 | 59 | Effect.gen(function* () { | 60 | 60 | const plugins = yield* Plugin.Service | 61 | 61 | const credentials = yield* Credential.Service | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/test/plugin/promise.test.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,7 +32,7 @@ import { host as testHost } from "./host" | 32 | 32 | const it = testEffect(PluginTestLayer) | 33 | 33 |
| 34 | 34 | describe("fromPromise", () => { | 35 | | - it.effect("refreshes its own stored OAuth connection during plugin activation", () => | | 35 | + it.live("refreshes its own stored OAuth connection during plugin activation", () => | 36 | 36 | Effect.gen(function* () { | 37 | 37 | const plugins = yield* Plugin.Service | 38 | 38 | const credentials = yield* Credential.Service | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/test/reference.test.ts +13-11Lines changed: 13 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,14 +9,15 @@ import { Global } from "@opencode-ai/util/global" | 9 | 9 | import { Reference } from "@opencode-ai/core/reference" | 10 | 10 | import { Repository } from "@opencode-ai/core/repository" | 11 | 11 | import { RepositoryCache } from "@opencode-ai/core/repository-cache" | 12 | | -import { it } from "./lib/effect" | | 12 | +import { it, testEffect } from "./lib/effect" | 13 | 13 |
| 14 | 14 | const cache = Layer.mock(RepositoryCache.Service, { | 15 | 15 | ensure: () => Effect.die("unexpected Git materialization"), | 16 | 16 | }) | 17 | 17 | const referenceLayer = AppNodeBuilder.build(LayerNode.group([Reference.node, Bus.node]), [ | 18 | 18 | [RepositoryCache.node, cache], | 19 | 19 | ]) | | 20 | +const referenceIt = testEffect(referenceLayer) | 20 | 21 |
| 21 | 22 | describe("Reference", () => { | 22 | 23 | it.effect("prepares batched references before cache work or update events", () => { | @@ -95,10 +96,10 @@ describe("Reference", () => { | 95 | 96 | refresh: input.refresh, | 96 | 97 | })), | 97 | 98 | ).toEqual([{ repository: "owner/repo", branch: "feature/docs", refresh: true }]) | 98 | | - }).pipe(Effect.provide(referenceLayer)) | | 99 | + }).pipe(Effect.scoped, Effect.provide(referenceLayer)) | 99 | 100 | }) | 100 | 101 |
| 101 | | - it.effect("lets update listeners replace references and refetch the latest projection", () => | | 102 | + referenceIt.effect("lets update listeners replace references and refetch the latest projection", () => | 102 | 103 | Effect.gen(function* () { | 103 | 104 | const references = yield* Reference.Service | 104 | 105 | const bus = yield* Bus.Service | @@ -133,13 +134,14 @@ describe("Reference", () => { | 133 | 134 |
| 134 | 135 | expect((yield* references.list()).map((info) => info.path)).toEqual([AbsolutePath.make("/new")]) | 135 | 136 | expect(observed).toEqual([["/new"], ["/new"]]) | 136 | | - }).pipe(Effect.provide(referenceLayer)), | | 137 | + }), | 137 | 138 | ) | 138 | 139 |
| 139 | | - it.effect("registers normalized sources for the owning scope", () => | | 140 | + referenceIt.effect("registers normalized sources for the owning scope", () => | 140 | 141 | Effect.gen(function* () { | 141 | 142 | const references = yield* Reference.Service | 142 | | - const scope = yield* Scope.make() | | 143 | + const parent = yield* Effect.scope | | 144 | + const scope = yield* Scope.fork(parent) | 143 | 145 | const path = AbsolutePath.make("/docs") | 144 | 146 | const source = Reference.LocalSource.make({ | 145 | 147 | type: "local", | @@ -155,10 +157,10 @@ describe("Reference", () => { | 155 | 157 |
| 156 | 158 | yield* Scope.close(scope, Exit.void) | 157 | 159 | expect(yield* references.list()).toEqual([]) | 158 | | - }).pipe(Effect.provide(referenceLayer)), | | 160 | + }), | 159 | 161 | ) | 160 | 162 |
| 161 | | - it.effect("derives Git paths without exposing cache operations", () => | | 163 | + referenceIt.effect("derives Git paths without exposing cache operations", () => | 162 | 164 | Effect.gen(function* () { | 163 | 165 | const references = yield* Reference.Service | 164 | 166 | const repository = Repository.parseRemote("owner/repo") | @@ -172,10 +174,10 @@ describe("Reference", () => { | 172 | 174 | source, | 173 | 175 | }), | 174 | 176 | ]) | 175 | | - }).pipe(Effect.scoped, Effect.provide(referenceLayer)), | | 177 | + }), | 176 | 178 | ) | 177 | 179 |
| 178 | | - it.effect("preserves configured Git descriptions", () => | | 180 | + referenceIt.effect("preserves configured Git descriptions", () => | 179 | 181 | Effect.gen(function* () { | 180 | 182 | const references = yield* Reference.Service | 181 | 183 | const repository = Repository.parseRemote("owner/repo") | @@ -194,6 +196,6 @@ describe("Reference", () => { | 194 | 196 | source, | 195 | 197 | }), | 196 | 198 | ]) | 197 | | - }).pipe(Effect.scoped, Effect.provide(referenceLayer)), | | 199 | + }), | 198 | 200 | ) | 199 | 201 | }) |
|