diff options
Diffstat (limited to 'test_lib')
| -rw-r--r-- | test_lib/transport.c | 29 | ||||
| -rw-r--r-- | test_lib/transport_test.h | 15 |
2 files changed, 44 insertions, 0 deletions
diff --git a/test_lib/transport.c b/test_lib/transport.c new file mode 100644 index 0000000..004bace --- /dev/null +++ b/test_lib/transport.c @@ -0,0 +1,29 @@ +#include "transport_test.h" +#include <assert.h> + +struct ExpectedRequest *nextResult = NULL; + +enum ReturnCode transport_request(char *url, enum HttpMethod method, char *token, char *reqBody, struct SizedBlock *retBody) { + assert(nextResult != NULL); + assert(strcmp(nextResult->url, url) == 0); + if(nextResult->reqBody == NULL) { + assert(nextResult->reqBody == NULL); + } else { + assert(reqBody != NULL); + assert(strcmp(nextResult->reqBody, reqBody) == 0); + } + + if(nextResult->token == NULL) { + assert(nextResult->token == NULL); + } else { + assert(token != NULL); + assert(strcmp(nextResult->token, token) == 0); + } + + + memcpy(retBody, &nextResult->retBody, sizeof(struct SizedBlock)); + + enum ReturnCode rc = nextResult->rc; + nextResult++; + return rc; +} diff --git a/test_lib/transport_test.h b/test_lib/transport_test.h new file mode 100644 index 0000000..ed6783b --- /dev/null +++ b/test_lib/transport_test.h @@ -0,0 +1,15 @@ +#pragma once + +#include "transport.h" + +struct ExpectedRequest { + bool ignore; + char *url; + char *token; + char *reqBody; + + struct SizedBlock retBody; + enum ReturnCode rc; +}; + +extern struct ExpectedRequest *nextResult; |
