Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Nov 19, 2023
1 parent 96c2e7d commit 58514fd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func TestGetProxies(t *testing.T) {
Network: config.DefaultNetwork,
Address: config.DefaultAddress,
}
client := network.NewClient(context.TODO(), clientConfig, zerolog.Logger{})
client := network.NewClient(context.TODO(), clientConfig, zerolog.Logger{}, nil)
newPool := pool.NewPool(context.TODO(), 1)
assert.Nil(t, newPool.Put(client.ID, client))

Expand Down Expand Up @@ -225,7 +225,7 @@ func TestGetServers(t *testing.T) {
Network: config.DefaultNetwork,
Address: config.DefaultAddress,
}
client := network.NewClient(context.TODO(), clientConfig, zerolog.Logger{})
client := network.NewClient(context.TODO(), clientConfig, zerolog.Logger{}, nil)
newPool := pool.NewPool(context.TODO(), 1)
assert.Nil(t, newPool.Put(client.ID, client))

Expand Down
11 changes: 6 additions & 5 deletions network/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func CreateNewClient(t *testing.T) *Client {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
},
logger)
logger,
nil)

return client
}
Expand Down Expand Up @@ -148,7 +149,7 @@ func BenchmarkNewClient(b *testing.B) {
DialTimeout: config.DefaultDialTimeout,
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
}, logger)
}, logger, nil)
client.Close()
}
}
Expand All @@ -174,7 +175,7 @@ func BenchmarkSend(b *testing.B) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
},
logger)
logger, nil)
defer client.Close()

packet := CreatePgStartupPacket()
Expand Down Expand Up @@ -205,7 +206,7 @@ func BenchmarkReceive(b *testing.B) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
},
logger)
logger, nil)
defer client.Close()

packet := CreatePgStartupPacket()
Expand Down Expand Up @@ -236,7 +237,7 @@ func BenchmarkIsConnected(b *testing.B) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
},
logger)
logger, nil)
defer client.Close()

for i := 0; i < b.N; i++ {
Expand Down
11 changes: 6 additions & 5 deletions network/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func TestNewProxy(t *testing.T) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
},
logger)
logger,
nil)
err := newPool.Put(client.ID, client)
assert.Nil(t, err)

Expand Down Expand Up @@ -232,7 +233,7 @@ func BenchmarkProxyConnectDisconnect(b *testing.B) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
}
newPool.Put("client", NewClient(context.Background(), &clientConfig, logger)) //nolint:errcheck
newPool.Put("client", NewClient(context.Background(), &clientConfig, logger, nil)) //nolint:errcheck

// Create a proxy with a fixed buffer newPool
proxy := NewProxy(
Expand Down Expand Up @@ -286,7 +287,7 @@ func BenchmarkProxyPassThrough(b *testing.B) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
}
newPool.Put("client", NewClient(context.Background(), &clientConfig, logger)) //nolint:errcheck
newPool.Put("client", NewClient(context.Background(), &clientConfig, logger, nil)) //nolint:errcheck

// Create a proxy with a fixed buffer newPool
proxy := NewProxy(
Expand Down Expand Up @@ -344,7 +345,7 @@ func BenchmarkProxyIsHealthyAndIsExhausted(b *testing.B) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
}
client := NewClient(context.Background(), &clientConfig, logger)
client := NewClient(context.Background(), &clientConfig, logger, nil)
newPool.Put("client", client) //nolint:errcheck

// Create a proxy with a fixed buffer newPool
Expand Down Expand Up @@ -401,7 +402,7 @@ func BenchmarkProxyAvailableAndBusyConnections(b *testing.B) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
}
client := NewClient(context.Background(), &clientConfig, logger)
client := NewClient(context.Background(), &clientConfig, logger, nil)
newPool.Put("client", client) //nolint:errcheck

// Create a proxy with a fixed buffer newPool
Expand Down
9 changes: 5 additions & 4 deletions network/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ func TestRunServer(t *testing.T) {

// Create a connection newPool.
newPool := pool.NewPool(context.Background(), 3)
client1 := NewClient(context.Background(), &clientConfig, logger)
client1 := NewClient(context.Background(), &clientConfig, logger, nil)
err := newPool.Put(client1.ID, client1)
assert.Nil(t, err)
client2 := NewClient(context.Background(), &clientConfig, logger)
client2 := NewClient(context.Background(), &clientConfig, logger, nil)
err = newPool.Put(client2.ID, client2)
assert.Nil(t, err)
client3 := NewClient(context.Background(), &clientConfig, logger)
client3 := NewClient(context.Background(), &clientConfig, logger, nil)
err = newPool.Put(client3.ID, client3)
assert.Nil(t, err)

Expand Down Expand Up @@ -138,7 +138,8 @@ func TestRunServer(t *testing.T) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: config.DefaultTCPKeepAlivePeriod,
},
logger)
logger,
nil)

assert.NotNil(t, client)
sent, err := client.Send(CreatePgStartupPacket())
Expand Down
2 changes: 1 addition & 1 deletion network/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func BenchmarkTrafficData(b *testing.B) {
TCPKeepAlive: false,
TCPKeepAlivePeriod: time.Second * 10,
ReceiveChunkSize: 1024,
}, logger)
}, logger, nil)
fields := []Field{
{
Name: "test",
Expand Down

0 comments on commit 58514fd

Please sign in to comment.