diff options
Diffstat (limited to 'tests/unit/stubs/esp_http_client.h')
| -rw-r--r-- | tests/unit/stubs/esp_http_client.h | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/tests/unit/stubs/esp_http_client.h b/tests/unit/stubs/esp_http_client.h index 4169714..288ce3b 100644 --- a/tests/unit/stubs/esp_http_client.h +++ b/tests/unit/stubs/esp_http_client.h | |||
| @@ -2,11 +2,52 @@ | |||
| 2 | #define STUBS_ESP_HTTP_CLIENT_H | 2 | #define STUBS_ESP_HTTP_CLIENT_H |
| 3 | 3 | ||
| 4 | #include "esp_err.h" | 4 | #include "esp_err.h" |
| 5 | #include <string.h> | ||
| 6 | #include <stdlib.h> | ||
| 5 | 7 | ||
| 6 | typedef void *esp_http_client_handle_t; | 8 | typedef enum { |
| 9 | HTTP_METHOD_GET = 0, | ||
| 10 | HTTP_METHOD_POST, | ||
| 11 | HTTP_METHOD_PUT, | ||
| 12 | HTTP_METHOD_DELETE, | ||
| 13 | } esp_http_client_method_t; | ||
| 14 | |||
| 15 | typedef void *esp_crt_bundle_attach_fn_t(void *conf); | ||
| 7 | 16 | ||
| 8 | typedef struct { | 17 | typedef struct { |
| 18 | const char *url; | ||
| 19 | esp_http_client_method_t method; | ||
| 20 | int timeout_ms; | ||
| 21 | esp_crt_bundle_attach_fn_t *crt_bundle_attach; | ||
| 9 | int cert_pem; | 22 | int cert_pem; |
| 10 | } esp_http_client_config_t; | 23 | } esp_http_client_config_t; |
| 11 | 24 | ||
| 25 | typedef void *esp_http_client_handle_t; | ||
| 26 | |||
| 27 | static inline esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *cfg) { | ||
| 28 | (void)cfg; | ||
| 29 | return (void *)malloc(1); | ||
| 30 | } | ||
| 31 | static inline esp_err_t esp_http_client_set_header(esp_http_client_handle_t c, const char *k, const char *v) { | ||
| 32 | (void)c; (void)k; (void)v; return ESP_OK; | ||
| 33 | } | ||
| 34 | static inline esp_err_t esp_http_client_open(esp_http_client_handle_t c, int len) { | ||
| 35 | (void)c; (void)len; return ESP_OK; | ||
| 36 | } | ||
| 37 | static inline int esp_http_client_write(esp_http_client_handle_t c, const char *buf, int len) { | ||
| 38 | (void)c; (void)buf; return len; | ||
| 39 | } | ||
| 40 | static inline int esp_http_client_fetch_headers(esp_http_client_handle_t c) { | ||
| 41 | (void)c; return 0; | ||
| 42 | } | ||
| 43 | static inline int esp_http_client_get_status_code(esp_http_client_handle_t c) { | ||
| 44 | (void)c; return 200; | ||
| 45 | } | ||
| 46 | static inline int esp_http_client_read(esp_http_client_handle_t c, char *buf, int len) { | ||
| 47 | (void)c; (void)buf; (void)len; return 0; | ||
| 48 | } | ||
| 49 | static inline esp_err_t esp_http_client_cleanup(esp_http_client_handle_t c) { | ||
| 50 | free(c); return ESP_OK; | ||
| 51 | } | ||
| 52 | |||
| 12 | #endif | 53 | #endif |