jackc / jackc/pgmock

Failed to connect to the database error: invalid page in block 22 of relation base/12971/2674

Open
#15 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
127
Forks
15
PR merge metrics
No merged PRs in 30d

Description

I am adding unit testing for my node.js application but getting the error while running ut, code for your reference.

const { Client } = require('pg');
const { PostgresMock } = require('pgmock');
const client = new Client({
user: "postgres",
host: "localhost",
database: "postgres",
password: "pgmock",
port: "5432",
});
async function connectToDatabase() {
try {
const mock = await PostgresMock.create();
const connectionString = await mock.listen(5432);
console.log("connectionString" + connectionString);
await client.connect();
console.debug("Connected to the postgres database named: " + "postgres");
await client.query(`CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)`);
console.log("Table created successfully");
} catch (err) {
console.error("Failed to connect to the database", err);
throw err;
}}
connectToDatabase();

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue contains only an inline Node.js script and no repository files or tests. Start by reproducing the script with pgmock and the PostgreSQL client, then inspect the connection setup and reported invalid-page error. Done means the example connects and creates the table successfully, or the issue documents the required configuration and a reliable reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, postgres
Domain
databases, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.