mirror of
https://gh-proxy.org/https://github.com/klinsmaya/CLIProxyAPI.git
synced 2026-11-10 02:16:49 +08:00
- 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.
26 lines
569 B
Go
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)
|
|
}
|
|
}
|