package jwt import ( "os" "testing" ) // TestMain 预置安全环境变量。config.GetConfig() 在 JWT_SECRET/ENCRYPTION_KEY // 缺失时会 log.Fatal,故必须在任何测试逻辑之前设置。 func TestMain(m *testing.M) { os.Setenv("JWT_SECRET", "jwt-pkg-test-secret-32chars-min!!") os.Setenv("ENCRYPTION_KEY", "jwt-pkg-test-encryption-32chars!!") os.Setenv("DATA_DIR", os.TempDir()+"/lokideploy-jwt-pkg-test") os.Exit(m.Run()) }