src/server/test/testutils.c

branch
webdav
changeset 233
c5985d2fc19a
parent 232
499711b2a970
child 251
f727a21497bb
--- a/src/server/test/testutils.c	Sat Jan 18 13:48:59 2020 +0100
+++ b/src/server/test/testutils.c	Sat Jan 18 16:31:52 2020 +0100
@@ -41,6 +41,7 @@
 Session* testutil_session(void) {
     pool_handle_t *pool = pool_create();
     NSAPISession *sn = nsapisession_create(pool);
+    sn->connection = testutil_dummy_connection(pool);
     
     return &sn->sn;
 }
@@ -75,6 +76,28 @@
     return &rq->rq;
 }
 
+static int dummyconn_read(Connection *conn, void *buf, int len) {
+    return len;
+}
+
+static int dummyconn_write(Connection *conn, const void *buf, int len) {
+    return len;
+}
+
+static void dummyconn_close(Connection *conn) {
+    
+}
+
+
+Connection* testutil_dummy_connection(pool_handle_t *pool) {
+    Connection *conn = pool_malloc(pool, sizeof(Connection));
+    ZERO(conn, sizeof(Connection));
+    conn->read = dummyconn_read;
+    conn->write = dummyconn_write;
+    conn->close = dummyconn_close; 
+    return conn;
+}
+
 void testutil_request_body(Session *sn, Request *rq, const char *body, size_t len) {
     sstr_t cl = ucx_sprintf("%d", (int)len);
     pblock_nvreplace("content-length", cl.ptr, rq->headers);

mercurial