Skip to content

Commit

Permalink
fix: server test
Browse files Browse the repository at this point in the history
  • Loading branch information
stanipetrosyan committed Aug 30, 2024
1 parent dc63521 commit 95249cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func (s *tcpClient) Connect() {
conn, err = net.Dial("tcp", s.address)
}

slog.Info("Connected to server", slog.String("address", conn.LocalAddr().String()))

defer conn.Close()

for {
Expand Down
2 changes: 2 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func (s *tcpServer) Listen() (Server, error) {
continue
}

slog.Info("Client Connected", slog.String("host", conn.LocalAddr().String()))

s.Lock()
s.clients = append(s.clients, conn)
s.Unlock()
Expand Down
5 changes: 3 additions & 2 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"sync"
"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -37,11 +38,11 @@ func TestServer(t *testing.T) {
assert.Equal(t, "my-channel", request.Channel)
assert.Equal(t, "Hello there", request.Message.Extract())
wg.Done()

}()

time.Sleep(time.Millisecond)

msg := CreateMessage().SetBody("Hello there")
server.Publish("my-channel", msg)
wg.Wait()

}

0 comments on commit 95249cb

Please sign in to comment.