Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/client/test/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, mock } from "bun:test";

// Mock the better-auth/client module - must be before AuthClient import
const mockSignUp = mock(async (params: { email: string; password: string; name: string }) => {
return {
Expand Down Expand Up @@ -79,7 +81,6 @@ mock.module("better-auth/client", () => ({
})),
}));

import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, mock } from "bun:test";
import { AuthClient } from "../src/auth";
import { AuthError, NetworkError } from "../src/errors";

Expand Down
15 changes: 5 additions & 10 deletions packages/core/test/branching.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,26 +397,21 @@ describe("branching/database - DatabaseBranching", () => {

describe("listPreviewDatabases", () => {
test("returns array of preview database names", async () => {
// Without actual DB connection, this will fail
// But we can verify it returns a promise
const promise = dbBranching.listPreviewDatabases();
expect(promise).toBeInstanceOf(Promise);
await expect(dbBranching.listPreviewDatabases()).rejects.toThrow();
});
});

describe("previewDatabaseExists", () => {
test("returns promise for checking database existence", async () => {
const promise = dbBranching.previewDatabaseExists("preview_test");
expect(promise).toBeInstanceOf(Promise);
await expect(dbBranching.previewDatabaseExists("preview_test")).rejects.toThrow();
});
});

describe("teardownPreviewDatabase", () => {
test("returns promise for teardown operation", async () => {
const promise = dbBranching.teardownPreviewDatabase(
"postgres://user:password@localhost:5432/preview_test",
);
expect(promise).toBeInstanceOf(Promise);
await expect(
dbBranching.teardownPreviewDatabase("postgres://user:password@localhost:5432/preview_test"),
).rejects.toThrow();
});
});
Comment on lines 398 to 416
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Test descriptions don't match test behavior.

The test names describe happy-path behavior ("returns array", "returns promise") but the assertions verify rejection on connection failure. This is misleading when tests fail or when reading the test output.

Suggested renames
 describe("listPreviewDatabases", () => {
-	test("returns array of preview database names", async () => {
+	test("rejects when database connection fails", async () => {
 		await expect(dbBranching.listPreviewDatabases()).rejects.toThrow();
 	});
 });

 describe("previewDatabaseExists", () => {
-	test("returns promise for checking database existence", async () => {
+	test("rejects when database connection fails", async () => {
 		await expect(dbBranching.previewDatabaseExists("preview_test")).rejects.toThrow();
 	});
 });

 describe("teardownPreviewDatabase", () => {
-	test("returns promise for teardown operation", async () => {
+	test("rejects when database connection fails", async () => {
 		await expect(
 			dbBranching.teardownPreviewDatabase("postgres://user:password@localhost:5432/preview_test"),
 		).rejects.toThrow();
 	});
 });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
describe("listPreviewDatabases", () => {
test("returns array of preview database names", async () => {
// Without actual DB connection, this will fail
// But we can verify it returns a promise
const promise = dbBranching.listPreviewDatabases();
expect(promise).toBeInstanceOf(Promise);
await expect(dbBranching.listPreviewDatabases()).rejects.toThrow();
});
});
describe("previewDatabaseExists", () => {
test("returns promise for checking database existence", async () => {
const promise = dbBranching.previewDatabaseExists("preview_test");
expect(promise).toBeInstanceOf(Promise);
await expect(dbBranching.previewDatabaseExists("preview_test")).rejects.toThrow();
});
});
describe("teardownPreviewDatabase", () => {
test("returns promise for teardown operation", async () => {
const promise = dbBranching.teardownPreviewDatabase(
"postgres://user:password@localhost:5432/preview_test",
);
expect(promise).toBeInstanceOf(Promise);
await expect(
dbBranching.teardownPreviewDatabase("postgres://user:password@localhost:5432/preview_test"),
).rejects.toThrow();
});
});
describe("listPreviewDatabases", () => {
test("rejects when database connection fails", async () => {
await expect(dbBranching.listPreviewDatabases()).rejects.toThrow();
});
});
describe("previewDatabaseExists", () => {
test("rejects when database connection fails", async () => {
await expect(dbBranching.previewDatabaseExists("preview_test")).rejects.toThrow();
});
});
describe("teardownPreviewDatabase", () => {
test("rejects when database connection fails", async () => {
await expect(
dbBranching.teardownPreviewDatabase("postgres://user:password@localhost:5432/preview_test"),
).rejects.toThrow();
});
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/test/branching.test.ts` around lines 398 - 416, Update the
three test titles to match the asserted failure behavior: change the
describe/test names for listPreviewDatabases, previewDatabaseExists, and
teardownPreviewDatabase (the tests calling dbBranching.listPreviewDatabases(),
dbBranching.previewDatabaseExists("preview_test"), and
dbBranching.teardownPreviewDatabase(...)) so they state they expect a rejection
on connection failure (e.g., "rejects when connection fails" or "throws on
connection error") instead of implying a successful return; alternatively, if
you intended to test the happy path, modify the assertions to await resolved
values rather than using rejects.toThrow().

});
Expand Down
Loading