(t *testing.T)
| 163 | } |
| 164 | |
| 165 | func TestWantConn_cancel_AlreadyDone(t *testing.T) { |
| 166 | w := &wantConn{ |
| 167 | ctx: context.Background(), |
| 168 | done: true, |
| 169 | result: make(chan wantConnResult, 1), |
| 170 | } |
| 171 | |
| 172 | // Put a result in the channel without connection (to avoid nil pointer issues) |
| 173 | testErr := errors.New("test error") |
| 174 | w.result <- wantConnResult{cn: nil, err: testErr} |
| 175 | |
| 176 | // Test cancel when already done |
| 177 | cn := w.cancel() |
| 178 | |
| 179 | // Should return nil since the result had no connection |
| 180 | if cn != nil { |
| 181 | t.Errorf("cancel()= %v, want nil when result had no connection", cn) |
| 182 | } |
| 183 | |
| 184 | // Check that wantConn remains done |
| 185 | if w.isOngoing() { |
| 186 | t.Error("wantConn.done = false, want true") |
| 187 | } |
| 188 | |
| 189 | // Check that context is cleared |
| 190 | if w.getCtxForDial() != nil { |
| 191 | t.Error("wantConn.ctx should be nil after cancel") |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | func TestWantConnQueue_newWantConnQueue(t *testing.T) { |
| 196 | q := newWantConnQueue() |
nothing calls this directly
no test coverage detected