(t *testing.T)
| 39 | } |
| 40 | |
| 41 | func TestWantConn_tryDeliver_Success(t *testing.T) { |
| 42 | w := &wantConn{ |
| 43 | ctx: context.Background(), |
| 44 | result: make(chan wantConnResult, 1), |
| 45 | } |
| 46 | |
| 47 | // Create a mock connection |
| 48 | conn := &Conn{} |
| 49 | |
| 50 | // Test successful delivery |
| 51 | delivered := w.tryDeliver(conn, nil) |
| 52 | if !delivered { |
| 53 | t.Error("tryDeliver() = false, want true") |
| 54 | } |
| 55 | |
| 56 | // Check that wantConn is marked as done |
| 57 | if w.isOngoing() { |
| 58 | t.Error("wantConn.done = false, want true after delivery") |
| 59 | } |
| 60 | |
| 61 | // Check that context is cleared |
| 62 | if w.getCtxForDial() != nil { |
| 63 | t.Error("wantConn.ctx should be nil after delivery") |
| 64 | } |
| 65 | |
| 66 | // Check that result is sent |
| 67 | select { |
| 68 | case result := <-w.result: |
| 69 | if result.cn != conn { |
| 70 | t.Errorf("result.cn = %v, want %v", result.cn, conn) |
| 71 | } |
| 72 | if result.err != nil { |
| 73 | t.Errorf("result.err = %v, want nil", result.err) |
| 74 | } |
| 75 | case <-time.After(time.Millisecond): |
| 76 | t.Error("Expected result to be sent to channel") |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | func TestWantConn_tryDeliver_WithError(t *testing.T) { |
| 81 | w := &wantConn{ |
nothing calls this directly
no test coverage detected