import { encryptText, decryptText } from './encryption.js';

const TEST_KEY = 'YixWi1MYh77NMEQYSJZR+2IsVotTGIe+zTBEGEiWUfs='; // 32 bytes base64

process.env.DATA_ENCRYPTION_KEY = TEST_KEY;

const run = async () => {
  const plain = 'Hello, World! 123';
  const encrypted = encryptText(plain);
  const decrypted = decryptText(encrypted);

  if (decrypted !== plain) {
    console.error('Decryption mismatch:', { plain, decrypted });
    process.exit(1);
  }

  console.log('Encryption tests passed');
};

run().catch((err) => {
  console.error('Encryption tests failed:', err.message);
  process.exit(1);
});