func TestConnReadErr(t *testing.T) {
	conn := &signalErrConn{
		signals: make(chan error),
	}

	ldapConn := NewConn(conn, false)
	ldapConn.Start()

	// Make a dummy search request.
	searchReq := NewSearchRequest("dc=example,dc=com", ScopeWholeSubtree, DerefAlways, 0, 0, false, "(objectClass=*)", nil, nil)

	expectedError := errors.New("this is the error you are looking for")

	// Send the signal after a short amount of time.
	time.AfterFunc(10*time.Millisecond, func() { conn.signals <- expectedError })

	// This should block until the underlying conn gets the error signal
	// which should bubble up through the reader() goroutine, close the
	// connection, and
	_, err := ldapConn.Search(searchReq)
	if err == nil || !strings.Contains(err.Error(), expectedError.Error()) {
		t.Errorf("not the expected error: %s", err)
	}
}
// TestConnReadErr tests that an unexpected error reading from underlying
// connection bubbles up to the goroutine which makes a request.
TestConnReadErr tests that an unexpected error reading from underlying
connection bubbles up to the goroutine which makes a request.
// TestConnReadErr tests that an unexpected error reading from underlying // connection bubbles up to the goroutine which makes a request .
func TestConnReadErr(t *testing.T) {
	conn := &signalErrConn{
		signals: make(chan error),
	}
	ldapConn := NewConn(conn, false)
	ldapConn.Start()
	searchReq := NewSearchRequest("dc=example,dc=com", ScopeWholeSubtree, DerefAlways, 0, 0, false, "(objectClass=*)", nil, nil)
	expectedError := errors.New("this is the error you are looking for")
	time.AfterFunc(10*time.Millisecond, func() { conn.signals <- expectedError })
	_, err := ldapConn.Search(searchReq)
	if err == nil || !strings.Contains(err.Error(), expectedError.Error()) {
		t.Errorf("not the expected error: %s", err)
	}
}
func TestConnReadErr ( t * testing . T ) { conn := & signalErrConn { signals : make ( chan error ) , } ldapConn := NewConn ( conn , false ) ldapConn . Start ( ) searchReq := NewSearchRequest ( " " , ScopeWholeSubtree , DerefAlways , 0 , 0 , false , " " , nil , nil ) expectedError := errors . New ( " " ) time . AfterFunc ( 10 * time . Millisecond , func ( ) { conn . signals <- expectedError } ) _ , err := ldapConn . Search ( searchReq ) if err == nil || ! strings . Contains ( err . Error ( ) , expectedError . Error ( ) ) { t . Errorf ( " " , err ) } }
TestConnReadErr tests that an unexpected error reading from underlying
connection bubbles up to the goroutine which makes a request.
TestConnReadErr tests that an unexpected error reading from underlying connection bubbles up to the goroutine which makes a request .
// Make a dummy search request. // Send the signal after a short amount of time. // This should block until the underlying conn gets the error signal // which should bubble up through the reader() goroutine, close the // connection, and