(t *testing.T)
| 124 | } |
| 125 | |
| 126 | func 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 | |
| 149 | func TestTask_AwaitResult_NilForNonexistent(t *testing.T) { |
| 150 | tm := NewTaskManager() |
nothing calls this directly
no test coverage detected