- Full Node.js application with Shopify GraphQL API integration - Compare At price support for promotional pricing - Comprehensive error handling and retry logic - Progress tracking with markdown logging - Complete test suite with unit and integration tests - Production-ready with proper exit codes and signal handling
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
// Test the getConfig function with caching
|
|
const { getConfig } = require("./src/config/environment");
|
|
|
|
console.log("Testing getConfig with caching...\n");
|
|
|
|
// Set up valid environment
|
|
process.env.SHOPIFY_SHOP_DOMAIN = "test-shop.myshopify.com";
|
|
process.env.SHOPIFY_ACCESS_TOKEN = "test-token-123456789";
|
|
process.env.TARGET_TAG = "sale";
|
|
process.env.PRICE_ADJUSTMENT_PERCENTAGE = "10";
|
|
|
|
try {
|
|
console.log("First call to getConfig():");
|
|
const config1 = getConfig();
|
|
console.log("✅ Config loaded:", {
|
|
shopDomain: config1.shopDomain,
|
|
targetTag: config1.targetTag,
|
|
priceAdjustmentPercentage: config1.priceAdjustmentPercentage,
|
|
});
|
|
|
|
console.log("\nSecond call to getConfig() (should use cache):");
|
|
const config2 = getConfig();
|
|
console.log("✅ Config loaded from cache:", {
|
|
shopDomain: config2.shopDomain,
|
|
targetTag: config2.targetTag,
|
|
priceAdjustmentPercentage: config2.priceAdjustmentPercentage,
|
|
});
|
|
|
|
console.log("\nVerifying same object reference (caching):");
|
|
console.log("Same object?", config1 === config2 ? "✅ Yes" : "❌ No");
|
|
} catch (error) {
|
|
console.log("❌ Error:", error.message);
|
|
}
|
|
|
|
console.log("\nCaching test completed!");
|