mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-21 19:35:10 +00:00
test: share empty well-known auth layer
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { expect } from "bun:test"
|
||||
import { AppFileSystem } from "@opencode-ai/core/filesystem"
|
||||
import { AuthWellKnown } from "@opencode-ai/core/auth-well-known"
|
||||
import { Substitution } from "@opencode-ai/core/substitution"
|
||||
import { Effect, Layer } from "effect"
|
||||
import path from "path"
|
||||
@@ -13,6 +12,7 @@ import { RuntimeFlags } from "../../src/effect/runtime-flags"
|
||||
import { Plugin } from "../../src/plugin"
|
||||
import { AccountTest } from "../fake/account"
|
||||
import { AuthTest } from "../fake/auth"
|
||||
import { AuthWellKnownTest } from "../fake/auth-well-known"
|
||||
import { NpmTest } from "../fake/npm"
|
||||
import { ProviderTest } from "../fake/provider"
|
||||
import { SkillTest } from "../fake/skill"
|
||||
@@ -25,12 +25,9 @@ import { PLUGIN_AGENT } from "../fixture/agent-plugin.constants"
|
||||
const pluginUrl = pathToFileURL(path.join(import.meta.dir, "..", "fixture", "agent-plugin.ts")).href
|
||||
|
||||
const provider = ProviderTest.fake()
|
||||
const emptyAuthWellKnown = Layer.mock(AuthWellKnown.Service)({
|
||||
configs: () => Effect.succeed([]),
|
||||
})
|
||||
const configLayer = Config.layer.pipe(
|
||||
Layer.provide(AppFileSystem.defaultLayer),
|
||||
Layer.provide(emptyAuthWellKnown),
|
||||
Layer.provide(AuthWellKnownTest.empty),
|
||||
Layer.provide(Substitution.defaultLayer),
|
||||
Layer.provide(Env.defaultLayer),
|
||||
Layer.provide(AuthTest.empty),
|
||||
|
||||
@@ -32,16 +32,13 @@ import { Filesystem } from "@/util/filesystem"
|
||||
import { ConfigPlugin } from "@/config/plugin"
|
||||
import { Npm } from "@opencode-ai/core/npm"
|
||||
import { Substitution } from "@opencode-ai/core/substitution"
|
||||
import { AuthWellKnownTest } from "../fake/auth-well-known"
|
||||
|
||||
const emptyAccount = Layer.mock(Account.Service)({
|
||||
active: () => Effect.succeed(Option.none()),
|
||||
activeOrg: () => Effect.succeed(Option.none()),
|
||||
})
|
||||
|
||||
const emptyAuthWellKnown = Layer.mock(AuthWellKnown.Service)({
|
||||
configs: () => Effect.succeed([]),
|
||||
})
|
||||
|
||||
const testFlock = EffectFlock.defaultLayer
|
||||
|
||||
const noopNpm = Layer.mock(Npm.Service)({
|
||||
@@ -58,7 +55,7 @@ const layer = Config.layer.pipe(
|
||||
Layer.provide(AppFileSystem.defaultLayer),
|
||||
Layer.provide(Substitution.defaultLayer),
|
||||
Layer.provide(Env.defaultLayer),
|
||||
Layer.provide(emptyAuthWellKnown),
|
||||
Layer.provide(AuthWellKnownTest.empty),
|
||||
Layer.provide(emptyAccount),
|
||||
Layer.provideMerge(infra),
|
||||
Layer.provide(noopNpm),
|
||||
@@ -595,7 +592,7 @@ test("resolves env templates in account config with account token", async () =>
|
||||
Layer.provide(AppFileSystem.defaultLayer),
|
||||
Layer.provide(Substitution.defaultLayer),
|
||||
Layer.provide(Env.defaultLayer),
|
||||
Layer.provide(emptyAuthWellKnown),
|
||||
Layer.provide(AuthWellKnownTest.empty),
|
||||
Layer.provide(fakeAccount),
|
||||
Layer.provideMerge(infra),
|
||||
Layer.provide(noopNpm),
|
||||
@@ -1107,7 +1104,7 @@ test("installs dependencies in writable OPENCODE_CONFIG_DIR", async () => {
|
||||
Layer.provide(AppFileSystem.defaultLayer),
|
||||
Layer.provide(Substitution.defaultLayer),
|
||||
Layer.provide(Env.defaultLayer),
|
||||
Layer.provide(emptyAuthWellKnown),
|
||||
Layer.provide(AuthWellKnownTest.empty),
|
||||
Layer.provide(emptyAccount),
|
||||
Layer.provideMerge(infra),
|
||||
Layer.provide(noopNpm),
|
||||
|
||||
8
packages/opencode/test/fake/auth-well-known.ts
Normal file
8
packages/opencode/test/fake/auth-well-known.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { AuthWellKnown } from "@opencode-ai/core/auth-well-known"
|
||||
import { Effect, Layer } from "effect"
|
||||
|
||||
export const AuthWellKnownTest = {
|
||||
empty: Layer.mock(AuthWellKnown.Service, {
|
||||
configs: () => Effect.succeed([]),
|
||||
}),
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import { Effect, Layer, Option } from "effect"
|
||||
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
||||
import { AppFileSystem } from "@opencode-ai/core/filesystem"
|
||||
import { EffectFlock } from "@opencode-ai/core/util/effect-flock"
|
||||
import { AuthWellKnown } from "@opencode-ai/core/auth-well-known"
|
||||
import { Substitution } from "@opencode-ai/core/substitution"
|
||||
import path from "path"
|
||||
import { pathToFileURL } from "url"
|
||||
@@ -18,6 +17,7 @@ import { ModelID, ProviderID } from "../../src/provider/schema"
|
||||
import { provideTmpdirInstance } from "../fixture/fixture"
|
||||
import { testEffect } from "../lib/effect"
|
||||
import { NpmTest } from "../fake/npm"
|
||||
import { AuthWellKnownTest } from "../fake/auth-well-known"
|
||||
|
||||
const emptyAccount = Layer.mock(Account.Service)({
|
||||
active: () => Effect.succeed(Option.none()),
|
||||
@@ -26,13 +26,10 @@ const emptyAccount = Layer.mock(Account.Service)({
|
||||
const emptyAuth = Layer.mock(Auth.Service)({
|
||||
all: () => Effect.succeed({}),
|
||||
})
|
||||
const emptyAuthWellKnown = Layer.mock(AuthWellKnown.Service)({
|
||||
configs: () => Effect.succeed([]),
|
||||
})
|
||||
const configLayer = Config.layer.pipe(
|
||||
Layer.provide(EffectFlock.defaultLayer),
|
||||
Layer.provide(AppFileSystem.defaultLayer),
|
||||
Layer.provide(emptyAuthWellKnown),
|
||||
Layer.provide(AuthWellKnownTest.empty),
|
||||
Layer.provide(Substitution.defaultLayer),
|
||||
Layer.provide(Env.defaultLayer),
|
||||
Layer.provide(emptyAuth),
|
||||
|
||||
@@ -4,7 +4,6 @@ import { FetchHttpClient } from "effect/unstable/http"
|
||||
import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
||||
import { AppFileSystem } from "@opencode-ai/core/filesystem"
|
||||
import { EffectFlock } from "@opencode-ai/core/util/effect-flock"
|
||||
import { AuthWellKnown } from "@opencode-ai/core/auth-well-known"
|
||||
import { Substitution } from "@opencode-ai/core/substitution"
|
||||
import path from "path"
|
||||
import { pathToFileURL } from "url"
|
||||
@@ -27,6 +26,7 @@ import { SyncEvent } from "../../src/sync"
|
||||
import { disposeAllInstances, provideTmpdirInstance } from "../fixture/fixture"
|
||||
import { testEffect } from "../lib/effect"
|
||||
import { NpmTest } from "../fake/npm"
|
||||
import { AuthWellKnownTest } from "../fake/auth-well-known"
|
||||
|
||||
const emptyAccount = Layer.mock(Account.Service)({
|
||||
active: () => Effect.succeed(Option.none()),
|
||||
@@ -35,13 +35,10 @@ const emptyAccount = Layer.mock(Account.Service)({
|
||||
const emptyAuth = Layer.mock(Auth.Service)({
|
||||
all: () => Effect.succeed({}),
|
||||
})
|
||||
const emptyAuthWellKnown = Layer.mock(AuthWellKnown.Service)({
|
||||
configs: () => Effect.succeed([]),
|
||||
})
|
||||
const configLayer = Config.layer.pipe(
|
||||
Layer.provide(EffectFlock.defaultLayer),
|
||||
Layer.provide(AppFileSystem.defaultLayer),
|
||||
Layer.provide(emptyAuthWellKnown),
|
||||
Layer.provide(AuthWellKnownTest.empty),
|
||||
Layer.provide(Substitution.defaultLayer),
|
||||
Layer.provide(Env.defaultLayer),
|
||||
Layer.provide(emptyAuth),
|
||||
|
||||
Reference in New Issue
Block a user