Download packages/core/test/credential.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/test/credential.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/core/test/credential.test.ts
-
curl -L -o credential.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/core/test/credential.test.ts
1.39 kB
| import { describe, expect } from "bun:test" | |
| import { Effect } from "effect" | |
| import { Credential } from "@opencode-ai/core/credential" | |
| import { LayerNode } from "@opencode-ai/core/effect/layer-node" | |
| import { Integration } from "@opencode-ai/core/integration" | |
| import { testEffect } from "./lib/effect" | |
| const it = testEffect(LayerNode.compile(Credential.node)) | |
| describe("Credential", () => { | |
| it.effect("stores, updates, lists, and removes credentials", () => | |
| Effect.gen(function* () { | |
| const credentials = yield* Credential.Service | |
| const integrationID = Integration.ID.make("openai") | |
| const created = yield* credentials.create({ | |
| integrationID, | |
| label: "Work", | |
| value: Credential.Key.make({ 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: Credential.Key.make({ type: "key", key: "replacement" }), | |
| }) | |
| expect(yield* credentials.list(integrationID)).toEqual([replacement]) | |
| yield* credentials.remove(replacement.id) | |
| expect(yield* credentials.list(integrationID)).toEqual([]) | |
| }), | |
| ) | |
| }) | |