/ opencodehub / scripts / test-storage-config.ts
Swadhin Biswas Feature/ai code reviewer (#73) · 8/2/2026
105a287
37 lines · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

import { getStorage, getStorageConfig } from "../src/lib/storage";

async function main() {
    console.log("--- Testing Storage Configuration ---");

    // 1. Check what getStorageConfig sees from env
    console.log("1. Environment Config:");
    const envConfig = getStorageConfig();
    console.log(`TYPE: ${envConfig.type}`);
    console.log(`PATH: ${envConfig.basePath}`);

    if (envConfig.type !== "local") {
        console.error("FAIL: Expected 'local' from env, got", envConfig.type);
    } else {
        console.log("PASS: Environment config is 'local'");
    }

    // 2. Check what getStorage returns (might verify DB logic too if DB connection works)
    console.log("\n2. Initializing Storage Adapter:");
    try {
        const storage = await getStorage();
        console.log("Storage initialized successfully");

        // Check if it's the right class
        if (storage.constructor.name === "LocalStorageAdapter") {
            console.log("PASS: Adapter is LocalStorageAdapter");
        } else {
            console.error(`FAIL: Adapter is ${storage.constructor.name}`);
        }
    } catch (err) {
        console.error("Error initializing storage:", err);
    }
}

main();