Files
opencode/packages/core/test/credential.test.ts
+21 8c94e9005f chore: merge dev into v2 (#34788)
Co-authored-by: Brendan Allan <[email protected]>
Co-authored-by: Kit Langton <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: Affan Ali <[email protected]>
Co-authored-by: affanali2k3 <[email protected]>
Co-authored-by: Frank <[email protected]>
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴 <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
Co-authored-by: Jay V <[email protected]>
Co-authored-by: Dax Raad <[email protected]>
Co-authored-by: Aarav Sareen <[email protected]>
Co-authored-by: OpeOginni <[email protected]>
Co-authored-by: Luke Parker <[email protected]>
Co-authored-by: Ben Guthrie <[email protected]>
Co-authored-by: Dax <[email protected]>
Co-authored-by: Filip <[email protected]>
Co-authored-by: Max Anderson <[email protected]>
Co-authored-by: Brendan Allan <[email protected]>
Co-authored-by: Jack <[email protected]>
Co-authored-by: Shoubhit Dash <[email protected]>
Co-authored-by: Dustin Deus <[email protected]>
Co-authored-by: starptech <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
Co-authored-by: usrnk1 <[email protected]>
Co-authored-by: Jay <[email protected]>
Co-authored-by: runvip <[email protected]>
Co-authored-by: opencode <[email protected]>
Co-authored-by: Julian Coy <[email protected]>
Co-authored-by: Vladimir Glafirov <[email protected]>
2026-07-01 17:12:00 -04:00

37 lines
1.4 KiB
TypeScript

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([])
}),
)
})