Skip to content
Snippets Groups Projects
Commit 1a21aecc authored by Federico Hurtado's avatar Federico Hurtado
Browse files

add a test user.

parent 21f76973
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,23 @@ console.log("Database Host: ", process.env.DB_HOST);
console.log("Database user: ", process.env.DB_USER);
console.log("Database name: ", process.env.DB_NAME);
// Function to add a test user
const addTestUser = () => {
return new Promise((resolve, reject) => {
const username = "fhurtado14"; // Example test username
const sql = "INSERT INTO users (username) VALUES (?)";
pool.query(sql, [username], (err, result) => {
if (err) {
console.error("Error inserting test user:", err);
return reject(err);
}
console.log("Test user inserted successfully.");
resolve(result);
});
});
};
// Function to execute the SQL file at initilization
const executeSQLFile = (filePath) => {
const sql = fs.readFileSync(filePath, "utf8");
......@@ -43,6 +60,11 @@ const executeSQLFile = (filePath) => {
}
console.log("SQL file executed successfully.");
connection.release();
// Now add the test user
addTestUser()
.then(() => console.log("Test user added."))
.catch((err) => console.error("Failed to add test user:", err));
});
});
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment