client: Windows 客户端(WinUI3 壳 + agent-core;调试用 Electron 壳存档);localserver token 改为常数时间比较
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package exec_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"everypublish/agentcore/internal/exec"
|
||||
"everypublish/agentcore/internal/exec/fake"
|
||||
"everypublish/shared/proto"
|
||||
)
|
||||
|
||||
func TestFakeExecutor(t *testing.T) {
|
||||
e := fake.Executor{SimMS: 5}
|
||||
start := time.Now()
|
||||
res := e.Execute(context.Background(), exec.Task{TaskID: "1", Platform: "douyin", Title: "t"})
|
||||
if time.Since(start) < 5*time.Millisecond {
|
||||
t.Fatal("should simulate delay")
|
||||
}
|
||||
if res.Status != "success" || res.PublishedURL == "" {
|
||||
t.Fatalf("expect success, got %+v", res)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFakeSolver(t *testing.T) {
|
||||
e := fake.Executor{SimMS: 1}
|
||||
solved, value := e.SolveChallenge(context.Background(), proto.Challenge{ChallengeID: "1"}, nil)
|
||||
if !solved || value == "" {
|
||||
t.Fatalf("expect solved, got %v %s", solved, value)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegistryFallback(t *testing.T) {
|
||||
r := exec.NewRegistry()
|
||||
r.SetFallback(fake.Executor{SimMS: 1})
|
||||
if r.Get("douyin") == nil {
|
||||
t.Fatal("fallback should serve any platform")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user