Add slog attributes at pool, worker, and connection levels.
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
func setupPool(t *testing.T) (*Pool, *honeybeetest.MockDialer) {
|
||||
t.Helper()
|
||||
pool, err := NewPool(context.Background(), nil, nil)
|
||||
pool, err := NewPool(context.Background(), "pool-1", nil, nil)
|
||||
assert.NoError(t, err)
|
||||
dialer := &honeybeetest.MockDialer{
|
||||
DialContextFunc: func(context.Context, string, http.Header) (types.Socket, *http.Response, error) {
|
||||
@@ -45,6 +45,11 @@ func expectEvent(
|
||||
|
||||
// Tests
|
||||
|
||||
func TestPoolID(t *testing.T) {
|
||||
_, err := NewPool(context.Background(), "", nil, nil)
|
||||
assert.ErrorIs(t, err, ErrInvalidPoolID)
|
||||
}
|
||||
|
||||
func TestPoolConnect(t *testing.T) {
|
||||
t.Run("successfully adds connection", func(t *testing.T) {
|
||||
pool, _ := setupPool(t)
|
||||
@@ -85,7 +90,7 @@ func TestPoolConnect(t *testing.T) {
|
||||
|
||||
func TestPoolClose(t *testing.T) {
|
||||
t.Run("channels close after pool close", func(t *testing.T) {
|
||||
pool, _ := NewPool(context.Background(), nil, nil)
|
||||
pool, _ := NewPool(context.Background(), "pool-1", nil, nil)
|
||||
pool.Close()
|
||||
_, ok := <-pool.Inbox()
|
||||
assert.False(t, ok)
|
||||
@@ -96,7 +101,7 @@ func TestPoolClose(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("connect after close returns error", func(t *testing.T) {
|
||||
pool, _ := NewPool(context.Background(), nil, nil)
|
||||
pool, _ := NewPool(context.Background(), "pool-1", nil, nil)
|
||||
pool.Close()
|
||||
err := pool.Connect("wss://test")
|
||||
assert.ErrorIs(t, err, ErrPoolClosed)
|
||||
@@ -154,7 +159,7 @@ func TestPoolSend(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
pool, err := NewPool(context.Background(), nil, nil)
|
||||
pool, err := NewPool(context.Background(), "pool-1", nil, nil)
|
||||
assert.NoError(t, err)
|
||||
pool.dialer = mockDialer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user