package crypto import ( "os" "testing" ) // TestMain 预置安全环境变量。deriveEncryptionKey 经 config.GetConfig() 读取 // ENCRYPTION_KEY,缺失或 <32 字符时 log.Fatal,故须先设置。 func TestMain(m *testing.M) { os.Setenv("JWT_SECRET", "crypto-pkg-test-secret-32chars!!") os.Setenv("ENCRYPTION_KEY", "crypto-pkg-test-encryption-32ch!!") os.Setenv("DATA_DIR", os.TempDir()+"/opsxloki-crypto-pkg-test") os.Exit(m.Run()) }