mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-03 23:53:46 +00:00
refactor: apply minimal tfcode branding
- Rename packages/opencode → packages/tfcode (directory only) - Rename bin/opencode → bin/tfcode (CLI binary) - Rename .opencode → .tfcode (config directory) - Update package.json name and bin field - Update config directory path references (.tfcode) - Keep internal code references as 'opencode' for easy upstream sync - Keep @opencode-ai/* workspace package names This minimal branding approach allows clean merges from upstream opencode repository while providing tfcode branding for users.
This commit is contained in:
58
packages/tfcode/test/auth/auth.test.ts
Normal file
58
packages/tfcode/test/auth/auth.test.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { test, expect } from "bun:test"
|
||||
import { Auth } from "../../src/auth"
|
||||
|
||||
test("set normalizes trailing slashes in keys", async () => {
|
||||
await Auth.set("https://example.com/", {
|
||||
type: "wellknown",
|
||||
key: "TOKEN",
|
||||
token: "abc",
|
||||
})
|
||||
const data = await Auth.all()
|
||||
expect(data["https://example.com"]).toBeDefined()
|
||||
expect(data["https://example.com/"]).toBeUndefined()
|
||||
})
|
||||
|
||||
test("set cleans up pre-existing trailing-slash entry", async () => {
|
||||
// Simulate a pre-fix entry with trailing slash
|
||||
await Auth.set("https://example.com/", {
|
||||
type: "wellknown",
|
||||
key: "TOKEN",
|
||||
token: "old",
|
||||
})
|
||||
// Re-login with normalized key (as the CLI does post-fix)
|
||||
await Auth.set("https://example.com", {
|
||||
type: "wellknown",
|
||||
key: "TOKEN",
|
||||
token: "new",
|
||||
})
|
||||
const data = await Auth.all()
|
||||
const keys = Object.keys(data).filter((k) => k.includes("example.com"))
|
||||
expect(keys).toEqual(["https://example.com"])
|
||||
const entry = data["https://example.com"]!
|
||||
expect(entry.type).toBe("wellknown")
|
||||
if (entry.type === "wellknown") expect(entry.token).toBe("new")
|
||||
})
|
||||
|
||||
test("remove deletes both trailing-slash and normalized keys", async () => {
|
||||
await Auth.set("https://example.com", {
|
||||
type: "wellknown",
|
||||
key: "TOKEN",
|
||||
token: "abc",
|
||||
})
|
||||
await Auth.remove("https://example.com/")
|
||||
const data = await Auth.all()
|
||||
expect(data["https://example.com"]).toBeUndefined()
|
||||
expect(data["https://example.com/"]).toBeUndefined()
|
||||
})
|
||||
|
||||
test("set and remove are no-ops on keys without trailing slashes", async () => {
|
||||
await Auth.set("anthropic", {
|
||||
type: "api",
|
||||
key: "sk-test",
|
||||
})
|
||||
const data = await Auth.all()
|
||||
expect(data["anthropic"]).toBeDefined()
|
||||
await Auth.remove("anthropic")
|
||||
const after = await Auth.all()
|
||||
expect(after["anthropic"]).toBeUndefined()
|
||||
})
|
||||
Reference in New Issue
Block a user