require('dotenv').config();
const customerDb = require('./services/customerDb');

async function test() {
    console.log("Testing Database Connection...");
    console.log(`Host: ${process.env.BILLING_DB_HOST}`);
    console.log(`User: ${process.env.BILLING_DB_USER}`);
    console.log(`DB: ${process.env.BILLING_DB_NAME}`);

    const isConnected = await customerDb.testConnection();
    if (isConnected) {
        console.log("✅ Connection Successful!");

        // Try to query a dummy number
        console.log("Testing query...");
        const customer = await customerDb.getCustomerByPhone('0812345678'); // Random number
        console.log("Query Result:", customer ? "Found" : "Not Found (This is expected for dummy number)");

    } else {
        console.log("❌ Connection Failed. Please check .env file.");
    }
    process.exit();
}

test();
