(t *testing.T)
| 128 | } |
| 129 | |
| 130 | func TestWantConn_cancel_NotDone(t *testing.T) { |
| 131 | w := &wantConn{ |
| 132 | ctx: context.Background(), |
| 133 | result: make(chan wantConnResult, 1), |
| 134 | } |
| 135 | |
| 136 | // Test cancel when not done |
| 137 | cn := w.cancel() |
| 138 | |
| 139 | // Should return nil since no connection was not delivered |
| 140 | if cn != nil { |
| 141 | t.Errorf("cancel()= %v, want nil when no connection delivered", cn) |
| 142 | } |
| 143 | |
| 144 | // Check that wantConn is marked as done |
| 145 | if w.isOngoing() { |
| 146 | t.Error("wantConn.done = false, want true after cancel") |
| 147 | } |
| 148 | |
| 149 | // Check that context is cleared |
| 150 | if w.getCtxForDial() != nil { |
| 151 | t.Error("wantConn.ctx should be nil after cancel") |
| 152 | } |
| 153 | |
| 154 | // Check that channel is closed |
| 155 | select { |
| 156 | case _, ok := <-w.result: |
| 157 | if ok { |
| 158 | t.Error("result channel should be closed after cancel") |
| 159 | } |
| 160 | case <-time.After(time.Millisecond): |
| 161 | t.Error("Expected channel to be closed") |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | func TestWantConn_cancel_AlreadyDone(t *testing.T) { |
| 166 | w := &wantConn{ |
nothing calls this directly
no test coverage detected