implement statuscode in packets
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 2m2s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 2m2s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"testing"
|
||||
)
|
||||
@@ -21,6 +22,10 @@ func TestCartTcpHelpers(t *testing.T) {
|
||||
messageData = string(data)
|
||||
return nil
|
||||
})
|
||||
server.HandleCall(666, func(id CartId, data []byte) (uint32, []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) {
|
||||
log.Printf("Received call: %s\n", string(data))
|
||||
return 3, []byte("Hello, client!"), nil
|
||||
@@ -34,6 +39,13 @@ func TestCartTcpHelpers(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Error calling: %v\n", err)
|
||||
}
|
||||
s, err := client.Call(666, id, 3, []byte("Hello, server!"))
|
||||
if err != nil {
|
||||
t.Errorf("Error calling: %v\n", err)
|
||||
}
|
||||
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 {
|
||||
@@ -44,8 +56,8 @@ func TestCartTcpHelpers(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Error calling: %v\n", err)
|
||||
}
|
||||
if string(answer) != "Hello, client!" {
|
||||
t.Errorf("Expected answer 'Hello, client!', got %s\n", string(answer))
|
||||
if string(answer.Data) != "Hello, client!" {
|
||||
t.Errorf("Expected answer 'Hello, client!', got %s\n", string(answer.Data))
|
||||
}
|
||||
if messageData != "Hello, world!" {
|
||||
t.Errorf("Expected message 'Hello, world!', got %s\n", messageData)
|
||||
|
||||
Reference in New Issue
Block a user