test_http_client.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include <stdlib.h>
  15. #include <stdbool.h>
  16. #include <esp_system.h>
  17. #include <esp_http_client.h>
  18. #include "unity.h"
  19. #include "test_utils.h"
  20. TEST_CASE("Input Param Tests", "[ESP HTTP CLIENT]")
  21. {
  22. esp_http_client_config_t config_incorrect = {0};
  23. test_case_uses_tcpip();
  24. esp_http_client_handle_t client = esp_http_client_init(&config_incorrect);
  25. TEST_ASSERT(client == NULL);
  26. esp_http_client_config_t config_with_url = {
  27. .url = "http://httpbin.org/get",
  28. };
  29. client = esp_http_client_init(&config_with_url);
  30. TEST_ASSERT(client != NULL);
  31. TEST_ASSERT(esp_http_client_cleanup(client) == ESP_OK);
  32. esp_http_client_config_t config_with_hostname_path = {
  33. .host = "httpbin.org",
  34. .path = "/get",
  35. };
  36. client = esp_http_client_init(&config_with_hostname_path);
  37. TEST_ASSERT(client != NULL);
  38. TEST_ASSERT(esp_http_client_cleanup(client) == ESP_OK);
  39. }