GeezerVison is showing github.com — test(ci): register omitted V2 unit suites (#45970) · anomalyco/opencode@51d53f4
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .gitattributes +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,3 +2,4 @@ packages/core/migration/**/snapshot.json linguist-generated | 2 | 2 | packages/core/src/database/migration.gen.ts linguist-generated | 3 | 3 | packages/core/src/models-dev/snapshot.txt linguist-generated | 4 | 4 | packages/core/src/**/*.txt text eol=lf | | 5 | +packages/httpapi-codegen/test/generated/*.ts text eol=lf |
Collapse file Copy file name to clipboardExpand all lines: packages/httpapi-codegen/test/generate.test.ts +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test" | 2 | 2 | import { mkdtemp, rm } from "node:fs/promises" | 3 | 3 | import { tmpdir } from "node:os" | 4 | 4 | import { join } from "node:path" | | 5 | +import { fileURLToPath } from "node:url" | 5 | 6 | import { Effect, FileSystem, Schema, SchemaAST, SchemaGetter } from "effect" | 6 | 7 | import { | 7 | 8 | HttpApi, | @@ -1096,7 +1097,7 @@ describe("HttpApiCodegen.generate", () => { | 1096 | 1097 | Effect.gen(function* () { | 1097 | 1098 | const output = compile(FixtureApi) | 1098 | 1099 | const actual = yield* Effect.promise(() => | 1099 | | - Array.fromAsync(new Bun.Glob("*.ts").scan(new URL("generated", import.meta.url).pathname)), | | 1100 | + Array.fromAsync(new Bun.Glob("*.ts").scan(fileURLToPath(new URL("generated", import.meta.url)))), | 1100 | 1101 | ) | 1101 | 1102 | expect(actual.sort((a, b) => a.localeCompare(b))).toEqual( | 1102 | 1103 | output.files.map((file) => file.path).sort((a, b) => a.localeCompare(b)), | |
Collapse file Copy file name to clipboardExpand all lines: packages/httpapi-codegen/test/write.test.ts +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { describe, expect } from "bun:test" | | 2 | +import { join } from "node:path" | 2 | 3 | import { Effect, FileSystem, Option } from "effect" | 3 | 4 | import { write, type Output } from "../src" | 4 | 5 | import { it } from "./effect" | @@ -15,8 +16,8 @@ describe("HttpApiCodegen.write", () => { | 15 | 16 | yield* write(output, "/generated") | 16 | 17 |
| 17 | 18 | expect(writes).toEqual([ | 18 | | - { path: "/generated/session.ts", content: "export const session = {}\n" }, | 19 | | - { path: "/generated/.httpapi-codegen.json", content: '["session.ts"]\n' }, | | 19 | + { path: join("/generated", "session.ts"), content: "export const session = {}\n" }, | | 20 | + { path: join("/generated", ".httpapi-codegen.json"), content: '["session.ts"]\n' }, | 20 | 21 | ]) | 21 | 22 | }).pipe( | 22 | 23 | Effect.provideService( | @@ -55,7 +56,7 @@ describe("HttpApiCodegen.write", () => { | 55 | 56 | writeFileString: () => Effect.void, | 56 | 57 | }), | 57 | 58 | ), | 58 | | - Effect.tap(() => Effect.sync(() => expect(removed).toEqual(["/generated/old.ts"]))), | | 59 | + Effect.tap(() => Effect.sync(() => expect(removed).toEqual([join("/generated", "old.ts")]))), | 59 | 60 | ) | 60 | 61 | }) | 61 | 62 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/server/test/fetch.test.ts +28-18Lines changed: 28 additions & 18 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import { ServerFetch } from "../src/fetch" | 11 | 11 | const options = { | 12 | 12 | app: { version: "test-version" }, | 13 | 13 | database: { path: ":memory:" }, | | 14 | + config: { project: false }, | 14 | 15 | models: { fetch: false }, | 15 | 16 | fs: { filewatcher: false }, | 16 | 17 | } as const | @@ -26,15 +27,20 @@ function occupy(port: number, cancel = false) { | 26 | 27 | server: createServer((request, response) => { | 27 | 28 | requests.push(request.url ?? "") | 28 | 29 | response.end(cancel ? "cancelled" : "still running", () => { | 29 | | - if (cancel) servers.forEach((item) => item.server.close()) | | 30 | + if (cancel) | | 31 | + servers.forEach((item) => { | | 32 | + // Bun clears its native handle in close(), so force-close connections first. | | 33 | + item.server.closeAllConnections() | | 34 | + item.server.close() | | 35 | + }) | 30 | 36 | }) | 31 | 37 | }), | 32 | 38 | })) | 33 | 39 | yield* Effect.addFinalizer(() => | 34 | 40 | Effect.forEach(servers, (item) => | 35 | 41 | Effect.callback<void>((resume) => { | 36 | | - item.server.close(() => resume(Effect.void)) | 37 | 42 | item.server.closeAllConnections() | | 43 | + item.server.close(() => resume(Effect.void)) | 38 | 44 | }), | 39 | 45 | ), | 40 | 46 | ) | @@ -154,22 +160,26 @@ it.live("falls back to port 1457 when OpenAI OAuth port 1455 remains busy", () = | 154 | 160 | }), | 155 | 161 | ) | 156 | 162 |
| 157 | | -it.live("explains how to recover when both OpenAI OAuth callback ports are busy", () => | 158 | | - Effect.gen(function* () { | 159 | | - yield* occupy(1455) | 160 | | - yield* occupy(1457) | 161 | | - const handler = yield* ServerFetch.make(options) | 162 | | - yield* ready(handler) | 163 | | - const response = yield* connectOpenAI(handler) | 164 | | - | 165 | | - expect(response.status).toBe(400) | 166 | | - expect(yield* Effect.promise(() => response.json())).toEqual({ | 167 | | - _tag: "InvalidRequestError", | 168 | | - message: | 169 | | - "OpenAI browser login needs local port 1455 or 1457, but both are already in use. Stop the processes using those ports or choose ChatGPT Pro/Plus (headless), then try again.", | 170 | | - kind: "integration_authorization", | 171 | | - }) | 172 | | - }), | | 163 | +it.live( | | 164 | + "explains how to recover when both OpenAI OAuth callback ports are busy", | | 165 | + () => | | 166 | + Effect.gen(function* () { | | 167 | + yield* occupy(1455) | | 168 | + yield* occupy(1457) | | 169 | + const handler = yield* ServerFetch.make(options) | | 170 | + yield* ready(handler) | | 171 | + const response = yield* connectOpenAI(handler) | | 172 | + | | 173 | + expect(response.status).toBe(400) | | 174 | + expect(yield* Effect.promise(() => response.json())).toEqual({ | | 175 | + _tag: "InvalidRequestError", | | 176 | + message: | | 177 | + "OpenAI browser login needs local port 1455 or 1457, but both are already in use. Stop the processes using those ports or choose ChatGPT Pro/Plus (headless), then try again.", | | 178 | + kind: "integration_authorization", | | 179 | + }) | | 180 | + }), | | 181 | + // Real retries wait 18 * 200 ms; startup and scoped cleanup also count toward the deadline. | | 182 | + { timeout: 10_000 }, | 173 | 183 | ) | 174 | 184 |
| 175 | 185 | it.live("treats destroying a missing workspace as success", () => | |
Collapse file Copy file name to clipboard +18-18Lines changed: 18 additions & 18 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { describe, expect, test } from "bun:test" | | 2 | +import { Effect } from "effect" | 2 | 3 |
| 3 | 4 | const forbidden = /["']@opencode-ai\/(?:core|sdk|server)(?:\/[^"']*)?["']/ | 4 | 5 | const oldSession = /(?:SessionV1|session-v1|legacy-message|legacy-message-values)/ | 5 | 6 |
| 6 | 7 | describe("Session UI package boundaries", () => { | 7 | 8 | test("does not import server runtime packages", async () => { | 8 | | - const files = new Bun.Glob("**/*.{ts,tsx}") | 9 | | - const violations: string[] = [] | 10 | | - | 11 | | - for await (const path of files.scan({ cwd: import.meta.dir, absolute: true })) { | 12 | | - if (path === import.meta.path) continue | 13 | | - if (forbidden.test(await Bun.file(path).text())) violations.push(path.slice(import.meta.dir.length + 1)) | 14 | | - } | 15 | | - | 16 | | - expect(violations).toEqual([]) | | 9 | + expect(await findViolations(forbidden)).toEqual([]) | 17 | 10 | }) | 18 | 11 |
| 19 | 12 | test("does not declare server runtime dependencies", async () => { | @@ -26,15 +19,7 @@ describe("Session UI package boundaries", () => { | 26 | 19 | }) | 27 | 20 |
| 28 | 21 | test("does not contain old Session message boundaries", async () => { | 29 | | - const files = new Bun.Glob("**/*.{ts,tsx}") | 30 | | - const violations: string[] = [] | 31 | | - | 32 | | - for await (const path of files.scan({ cwd: import.meta.dir, absolute: true })) { | 33 | | - if (path === import.meta.path) continue | 34 | | - if (oldSession.test(await Bun.file(path).text())) violations.push(path.slice(import.meta.dir.length + 1)) | 35 | | - } | 36 | | - | 37 | | - expect(violations).toEqual([]) | | 22 | + expect(await findViolations(oldSession)).toEqual([]) | 38 | 23 | }) | 39 | 24 |
| 40 | 25 | test("exports the current Session document surface", async () => { | @@ -49,3 +34,18 @@ describe("Session UI package boundaries", () => { | 49 | 34 | expect(exports["./timeline/projection"]).toBe("./src/timeline/projection.ts") | 50 | 35 | }) | 51 | 36 | }) | | 37 | + | | 38 | +async function findViolations(pattern: RegExp) { | | 39 | + const files = await Array.fromAsync(new Bun.Glob("**/*.{ts,tsx}").scan({ cwd: import.meta.dir, absolute: true })) | | 40 | + const matches = await Effect.runPromise( | | 41 | + Effect.forEach( | | 42 | + files.filter((path) => path !== import.meta.path), | | 43 | + (path) => | | 44 | + Effect.promise(async () => | | 45 | + pattern.test(await Bun.file(path).text()) ? path.slice(import.meta.dir.length + 1) : undefined, | | 46 | + ), | | 47 | + { concurrency: 8 }, | | 48 | + ), | | 49 | + ) | | 50 | + return matches.filter((path) => path !== undefined) | | 51 | +} |
Collapse file Copy file name to clipboardExpand all lines: turbo.json +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 34 | 34 | "dependsOn": [], | 35 | 35 | "outputs": ["dist/**"] | 36 | 36 | }, | | 37 | + "@opencode-ai/ai#test": { | | 38 | + "dependsOn": ["^build"], | | 39 | + "outputs": [] | | 40 | + }, | 37 | 41 | "@opencode-ai/codemode#test": { | 38 | 42 | "dependsOn": ["^build"], | 39 | 43 | "outputs": [] | | 45 | 49 | "@opencode-ai/function#test": { | 46 | 50 | "outputs": [] | 47 | 51 | }, | | 52 | + "@opencode-ai/httpapi-codegen#test": { | | 53 | + "outputs": [] | | 54 | + }, | | 55 | + "@opencode-ai/server#test": { | | 56 | + "dependsOn": ["^build"], | | 57 | + "outputs": [] | | 58 | + }, | 48 | 59 | "@opencode-ai/cli#test": { | 49 | 60 | "dependsOn": ["^build"], | 50 | 61 | "outputs": [] | |
|