test(server): use AppFileSystem in provider tests (#27227)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { describe, expect } from "bun:test"
|
import { describe, expect } from "bun:test"
|
||||||
import { Effect, FileSystem, Layer, Path } from "effect"
|
import { AppFileSystem } from "@opencode-ai/core/filesystem"
|
||||||
import { NodeFileSystem, NodePath } from "@effect/platform-node"
|
import { Effect, Layer } from "effect"
|
||||||
|
import path from "path"
|
||||||
import { Server } from "../../src/server/server"
|
import { Server } from "../../src/server/server"
|
||||||
import * as Log from "@opencode-ai/core/util/log"
|
import * as Log from "@opencode-ai/core/util/log"
|
||||||
import { resetDatabase } from "../fixture/db"
|
import { resetDatabase } from "../fixture/db"
|
||||||
@@ -16,7 +17,7 @@ const testStateLayer = Layer.effectDiscard(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
const it = testEffect(Layer.mergeAll(testStateLayer, NodeFileSystem.layer, NodePath.layer))
|
const it = testEffect(Layer.mergeAll(testStateLayer, AppFileSystem.defaultLayer))
|
||||||
const projectOptions = { config: { formatter: false, lsp: false } }
|
const projectOptions = { config: { formatter: false, lsp: false } }
|
||||||
const providerID = "test-oauth-parity"
|
const providerID = "test-oauth-parity"
|
||||||
const oauthURL = "https://example.com/oauth"
|
const oauthURL = "https://example.com/oauth"
|
||||||
@@ -95,11 +96,9 @@ function requestAuthorize(input: {
|
|||||||
|
|
||||||
function writeProviderAuthPlugin(dir: string) {
|
function writeProviderAuthPlugin(dir: string) {
|
||||||
return Effect.gen(function* () {
|
return Effect.gen(function* () {
|
||||||
const fs = yield* FileSystem.FileSystem
|
const fs = yield* AppFileSystem.Service
|
||||||
const path = yield* Path.Path
|
|
||||||
|
|
||||||
yield* fs.makeDirectory(path.join(dir, ".opencode", "plugin"), { recursive: true })
|
yield* fs.writeWithDirs(
|
||||||
yield* fs.writeFileString(
|
|
||||||
path.join(dir, ".opencode", "plugin", "provider-oauth-parity.ts"),
|
path.join(dir, ".opencode", "plugin", "provider-oauth-parity.ts"),
|
||||||
[
|
[
|
||||||
"export default {",
|
"export default {",
|
||||||
@@ -131,11 +130,9 @@ function writeProviderAuthPlugin(dir: string) {
|
|||||||
|
|
||||||
function writeFunctionOptionsPlugin(dir: string) {
|
function writeFunctionOptionsPlugin(dir: string) {
|
||||||
return Effect.gen(function* () {
|
return Effect.gen(function* () {
|
||||||
const fs = yield* FileSystem.FileSystem
|
const fs = yield* AppFileSystem.Service
|
||||||
const path = yield* Path.Path
|
|
||||||
|
|
||||||
yield* fs.makeDirectory(path.join(dir, ".opencode", "plugin"), { recursive: true })
|
yield* fs.writeWithDirs(
|
||||||
yield* fs.writeFileString(
|
|
||||||
path.join(dir, ".opencode", "plugin", "provider-function-options.ts"),
|
path.join(dir, ".opencode", "plugin", "provider-function-options.ts"),
|
||||||
[
|
[
|
||||||
"export default {",
|
"export default {",
|
||||||
@@ -164,11 +161,9 @@ function writeFunctionOptionsPlugin(dir: string) {
|
|||||||
|
|
||||||
function writeProviderModelsMutationPlugin(dir: string) {
|
function writeProviderModelsMutationPlugin(dir: string) {
|
||||||
return Effect.gen(function* () {
|
return Effect.gen(function* () {
|
||||||
const fs = yield* FileSystem.FileSystem
|
const fs = yield* AppFileSystem.Service
|
||||||
const path = yield* Path.Path
|
|
||||||
|
|
||||||
yield* fs.makeDirectory(path.join(dir, ".opencode", "plugin"), { recursive: true })
|
yield* fs.writeWithDirs(
|
||||||
yield* fs.writeFileString(
|
|
||||||
path.join(dir, ".opencode", "plugin", "provider-models-mutation.ts"),
|
path.join(dir, ".opencode", "plugin", "provider-models-mutation.ts"),
|
||||||
[
|
[
|
||||||
"export default {",
|
"export default {",
|
||||||
|
|||||||
Reference in New Issue
Block a user