From 60577a44cfd9b78e8f5db906e2ef3ce51bf8c121 Mon Sep 17 00:00:00 2001 From: Jack Ye Date: Wed, 23 Sep 2026 21:45:29 -0700 Subject: [PATCH] test(nodejs): cover the accepted and inline view drop through connect() Exercises `dropViewAsync` against the mock server both ways: a 202 carrying a `job_id` surfaces that id, and a 200 -- nothing was bound to the name -- yields an already-finished job with none. The wire key is written as raw JSON rather than an object literal, which is what the rest of this file does and what keeps `useNamingConvention` off a snake_case field the server chooses. --- nodejs/__test__/remote.test.ts | 31 +++++++++++++++++++++++++++++++ nodejs/lancedb/connection.ts | 5 +---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/nodejs/__test__/remote.test.ts b/nodejs/__test__/remote.test.ts index 4c1d21604..ffac7aae1 100644 --- a/nodejs/__test__/remote.test.ts +++ b/nodejs/__test__/remote.test.ts @@ -161,6 +161,37 @@ describe("remote connection", () => { ); }); + it("reports the cleanup job when a view drop is accepted", async () => { + await withMockDatabase( + (req, res) => { + expect(req.method).toBe("POST"); + expect(req.url).toBe("/v1/view/adults/drop"); + res + .writeHead(202, { "content-type": "application/json" }) + .end('{"job_id": "j1-do-abc"}'); + }, + async (db) => { + const job = await db.dropViewAsync("adults"); + expect(job.id).toBe("j1-do-abc"); + }, + ); + }); + + it("reports a finished job when a view drop had nothing to delete", async () => { + await withMockDatabase( + (req, res) => { + expect(req.url).toBe("/v1/view/adults/drop"); + res.writeHead(200, { "content-type": "application/json" }).end("{}"); + }, + async (db) => { + // A 200 means the name was not bound, so there is no cleanup to wait on. + const job = await db.dropViewAsync("adults"); + expect(job.id).toBeNull(); + await job.wait(); + }, + ); + }); + it("should accept partial connection options", async () => { await connect("db://test", { apiKey: "fake", diff --git a/nodejs/lancedb/connection.ts b/nodejs/lancedb/connection.ts index b525ff5f9..40b5ce72a 100644 --- a/nodejs/lancedb/connection.ts +++ b/nodejs/lancedb/connection.ts @@ -418,10 +418,7 @@ export abstract class Connection { * The name is free before this resolves. When nothing was bound to it, the * returned job is already finished and has no id. */ - abstract dropViewAsync( - name: string, - namespacePath?: string[], - ): Promise; + abstract dropViewAsync(name: string, namespacePath?: string[]): Promise; /** * The names of the views in one namespace.