Files
CLIProxyAPI/examples/plugin/jshandler/engine_test.go
T
Luis Pater 583053509d feat(jshandler): add new plugin providing JavaScript-based interceptors and capabilities
- Implemented `RequestInterceptor`, `ResponseInterceptor`, and `StreamChunkInterceptor` using embedded JavaScript.
- Added support for configuring script paths, built-in script resolution, and safe execution.
- Introduced ABI lifecycle management, plugin registration, and execution monitoring.
- Enhanced with extensive test coverage for both plugin behavior and configuration logic.
2026-06-09 08:28:00 +08:00

26 lines
569 B
Go

package main
import (
"testing"
"time"
)
func TestStopInterruptTimerClearsExpiredInterrupt(t *testing.T) {
engine := newJSEngine()
timer, done := engine.startInterruptTimer(time.Nanosecond)
select {
case <-done:
case <-time.After(time.Second):
t.Fatal("interrupt timer did not fire")
}
engine.stopInterruptTimer(timer, done)
value, errRun := engine.vm.RunString("1 + 1")
if errRun != nil {
t.Fatalf("RunString() error after clearing interrupt = %v", errRun)
}
if got := value.ToInteger(); got != 2 {
t.Fatalf("RunString() = %d, want 2", got)
}
}