Add new unit tests on engine

This commit is contained in:
armirveliaj
2024-09-04 10:05:36 -04:00
committed by Dan Christian Bogos
parent 35ae6ebd27
commit 8fe0fc0cf0
2 changed files with 227 additions and 0 deletions

View File

@@ -128,3 +128,19 @@ func TestHandleRequestCORSHeaders(t *testing.T) {
t.Errorf("Expected <%v>; got <%v>", expectedHeaders, got)
}
}
func TestRpcRequestWrite(t *testing.T) {
var buf bytes.Buffer
req := &rpcRequest{rw: &buf}
data := []byte("data, write!")
n, err := req.Write(data)
if err != nil {
t.Fatalf("Unexpected error during write: %v", err)
}
if n != len(data) {
t.Errorf("Expected %d bytes to be written, but got %d", len(data), n)
}
if buf.String() != string(data) {
t.Errorf("Expected buffer to contain %q, but got %q", data, buf.String())
}
}