types cleanup
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 28s
Build and Publish / BuildAndDeploy (push) Successful in 2m22s

This commit is contained in:
matst80
2024-11-12 18:17:43 +01:00
parent 3f8cdec9af
commit 7e0f070637
11 changed files with 75 additions and 73 deletions

View File

@@ -22,17 +22,17 @@ func TestCartTcpHelpers(t *testing.T) {
messageData = string(data)
return nil
})
server.HandleCall(666, func(id CartId, data []byte) (uint32, []byte, error) {
server.HandleCall(666, func(id CartId, data []byte) (CartMessage, []byte, error) {
log.Printf("Received call: %s\n", string(data))
return 3, []byte("Hello, client!"), fmt.Errorf("Det blev fel")
})
server.HandleCall(2, func(id CartId, data []byte) (uint32, []byte, error) {
server.HandleCall(2, func(id CartId, data []byte) (CartMessage, []byte, error) {
log.Printf("Received call: %s\n", string(data))
return 3, []byte("Hello, client!"), nil
})
server.HandleCall(Ping, func(id CartId, data []byte) (uint32, []byte, error) {
return Pong, nil, nil
})
// server.HandleCall(Ping, func(id CartId, data []byte) (CartMessage, []byte, error) {
// return Pong, nil, nil
// })
id := ToCartId("kalle")
client.SendPacket(1, id, []byte("Hello, world!"))
answer, err := client.Call(2, id, 3, []byte("Hello, server!"))
@@ -46,16 +46,7 @@ func TestCartTcpHelpers(t *testing.T) {
if s.StatusCode != 500 {
t.Errorf("Expected 500, got %d\n", s.StatusCode)
}
for i := 0; i < 100; i++ {
_, err = client.Call(Ping, id, Pong, nil)
if err != nil {
t.Errorf("Error calling: %v\n", err)
}
}
_, err = client.Call(Ping, id, Pong, nil)
if err != nil {
t.Errorf("Error calling: %v\n", err)
}
if string(answer.Data) != "Hello, client!" {
t.Errorf("Expected answer 'Hello, client!', got %s\n", string(answer.Data))
}