Buckets:
| import path from "path" | |
| import { describe, expect } from "bun:test" | |
| import { Effect, Layer } from "effect" | |
| import { Credential } from "@opencode-ai/core/credential" | |
| import { Database } from "@opencode-ai/core/database/database" | |
| import { Integration } from "@opencode-ai/core/integration" | |
| import { tmpdir } from "./fixture/tmpdir" | |
| import { it } from "./lib/effect" | |
| function layer(directory: string) { | |
| return Credential.layer.pipe( | |
| Layer.provide(Database.layerFromPath(path.join(directory, "credential.db")).pipe(Layer.fresh)), | |
| ) | |
| } | |
| describe("Credential", () => { | |
| it.live("stores, updates, lists, and removes credentials", () => | |
| Effect.acquireRelease( | |
| Effect.promise(() => tmpdir()), | |
| (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()), | |
| ).pipe( | |
| Effect.flatMap((tmp) => | |
| Effect.gen(function* () { | |
| const credentials = yield* Credential.Service | |
| const integrationID = Integration.ID.make("openai") | |
| const created = yield* credentials.create({ | |
| integrationID, | |
| label: "Work", | |
| value: new Credential.Key({ type: "key", key: "secret" }), | |
| }) | |
| expect(yield* credentials.list(integrationID)).toEqual([created]) | |
| yield* credentials.update(created.id, { label: "Personal" }) | |
| expect((yield* credentials.list(integrationID))[0]?.label).toBe("Personal") | |
| const replacement = yield* credentials.create({ | |
| integrationID, | |
| label: "Replacement", | |
| value: new Credential.Key({ type: "key", key: "replacement" }), | |
| }) | |
| expect(yield* credentials.list(integrationID)).toEqual([replacement]) | |
| yield* credentials.remove(replacement.id) | |
| expect(yield* credentials.list(integrationID)).toEqual([]) | |
| }).pipe(Effect.provide(layer(tmp.path))), | |
| ), | |
| ), | |
| ) | |
| }) | |
Xet Storage Details
- Size:
- 1.87 kB
- Xet hash:
- fe7e81f484f6324226bf88a70b2127938434eca0718e88ed05a5a10c2ff06f4b
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.