MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / TestTask_AwaitResult

Function TestTask_AwaitResult

internal/bridge/taskmanager_test.go:126–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestTask_AwaitResult(t *testing.T) {
127 tm := NewTaskManager()
128 tm.Create("sess-1", 1, "exec")
129
130 ch := tm.AwaitResult("sess-1", 1)
131 if ch == nil {
132 t.Fatal("AwaitResult should return non-nil channel")
133 }
134
135 // Send a result directly to the task's channel.
136 task := tm.Get("sess-1", 1)
137 task.resultCh <- &sessions.CommandResult{
138 TaskID: 1,
139 SessionID: "sess-1",
140 Output: "hello",
141 }
142
143 result := <-ch
144 if result.Output != "hello" {
145 t.Errorf("output: got %q, want %q", result.Output, "hello")
146 }
147}
148
149func TestTask_AwaitResult_NilForNonexistent(t *testing.T) {
150 tm := NewTaskManager()

Callers

nothing calls this directly

Calls 4

CreateMethod · 0.95
AwaitResultMethod · 0.95
GetMethod · 0.95
NewTaskManagerFunction · 0.85

Tested by

no test coverage detected