Explorar o código

chore: generate

opencode-agent[bot] hai 3 meses
pai
achega
673226d214
Modificáronse 1 ficheiros con 65 adicións e 59 borrados
  1. 65 59
      packages/opencode/test/server/session-select.test.ts

+ 65 - 59
packages/opencode/test/server/session-select.test.ts

@@ -11,77 +11,83 @@ void Log.init({ print: false })
 const it = testEffect(Session.defaultLayer)
 const it = testEffect(Session.defaultLayer)
 
 
 describe("tui.selectSession endpoint", () => {
 describe("tui.selectSession endpoint", () => {
-  it.instance("should return 200 when called with valid session", () =>
-    Effect.gen(function* () {
-      const tmp = yield* TestInstance
-      const session = yield* Session.Service.use((svc) => svc.create({}))
+  it.instance(
+    "should return 200 when called with valid session",
+    () =>
+      Effect.gen(function* () {
+        const tmp = yield* TestInstance
+        const session = yield* Session.Service.use((svc) => svc.create({}))
 
 
-      const app = Server.Default().app
-      const response = yield* Effect.promise(() =>
-        Promise.resolve(
-          app.request("/tui/select-session", {
-            method: "POST",
-            headers: {
-              "Content-Type": "application/json",
-              "x-opencode-directory": tmp.directory,
-            },
-            body: JSON.stringify({ sessionID: session.id }),
-          }),
-        ),
-      )
+        const app = Server.Default().app
+        const response = yield* Effect.promise(() =>
+          Promise.resolve(
+            app.request("/tui/select-session", {
+              method: "POST",
+              headers: {
+                "Content-Type": "application/json",
+                "x-opencode-directory": tmp.directory,
+              },
+              body: JSON.stringify({ sessionID: session.id }),
+            }),
+          ),
+        )
 
 
-      expect(response.status).toBe(200)
-      const body = yield* Effect.promise(() => response.json())
-      expect(body).toBe(true)
-    }),
+        expect(response.status).toBe(200)
+        const body = yield* Effect.promise(() => response.json())
+        expect(body).toBe(true)
+      }),
     { git: true },
     { git: true },
   )
   )
 
 
-  it.instance("should return 404 when session does not exist", () =>
-    Effect.gen(function* () {
-      const tmp = yield* TestInstance
-      const nonExistentSessionID = "ses_nonexistent123"
+  it.instance(
+    "should return 404 when session does not exist",
+    () =>
+      Effect.gen(function* () {
+        const tmp = yield* TestInstance
+        const nonExistentSessionID = "ses_nonexistent123"
 
 
-      const app = Server.Default().app
-      const response = yield* Effect.promise(() =>
-        Promise.resolve(
-          app.request("/tui/select-session", {
-            method: "POST",
-            headers: {
-              "Content-Type": "application/json",
-              "x-opencode-directory": tmp.directory,
-            },
-            body: JSON.stringify({ sessionID: nonExistentSessionID }),
-          }),
-        ),
-      )
+        const app = Server.Default().app
+        const response = yield* Effect.promise(() =>
+          Promise.resolve(
+            app.request("/tui/select-session", {
+              method: "POST",
+              headers: {
+                "Content-Type": "application/json",
+                "x-opencode-directory": tmp.directory,
+              },
+              body: JSON.stringify({ sessionID: nonExistentSessionID }),
+            }),
+          ),
+        )
 
 
-      expect(response.status).toBe(404)
-    }),
+        expect(response.status).toBe(404)
+      }),
     { git: true },
     { git: true },
   )
   )
 
 
-  it.instance("should return 400 when session ID format is invalid", () =>
-    Effect.gen(function* () {
-      const tmp = yield* TestInstance
-      const invalidSessionID = "invalid_session_id"
+  it.instance(
+    "should return 400 when session ID format is invalid",
+    () =>
+      Effect.gen(function* () {
+        const tmp = yield* TestInstance
+        const invalidSessionID = "invalid_session_id"
 
 
-      const app = Server.Default().app
-      const response = yield* Effect.promise(() =>
-        Promise.resolve(
-          app.request("/tui/select-session", {
-            method: "POST",
-            headers: {
-              "Content-Type": "application/json",
-              "x-opencode-directory": tmp.directory,
-            },
-            body: JSON.stringify({ sessionID: invalidSessionID }),
-          }),
-        ),
-      )
+        const app = Server.Default().app
+        const response = yield* Effect.promise(() =>
+          Promise.resolve(
+            app.request("/tui/select-session", {
+              method: "POST",
+              headers: {
+                "Content-Type": "application/json",
+                "x-opencode-directory": tmp.directory,
+              },
+              body: JSON.stringify({ sessionID: invalidSessionID }),
+            }),
+          ),
+        )
 
 
-      expect(response.status).toBe(400)
-    }),
+        expect(response.status).toBe(400)
+      }),
     { git: true },
     { git: true },
   )
   )
 })
 })