esp-idf/components/esp_http_client/test/test_http_client.c

48 lines
1.5 KiB
C

// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <stdlib.h>
#include <stdbool.h>
#include <esp_system.h>
#include <esp_http_client.h>
#include "unity.h"
#include "test_utils.h"
TEST_CASE("Input Param Tests", "[ESP HTTP CLIENT]")
{
esp_http_client_config_t config_incorrect = {0};
test_case_uses_tcpip();
esp_http_client_handle_t client = esp_http_client_init(&config_incorrect);
TEST_ASSERT(client == NULL);
esp_http_client_config_t config_with_url = {
.url = "http://httpbin.org/get",
};
client = esp_http_client_init(&config_with_url);
TEST_ASSERT(client != NULL);
TEST_ASSERT(esp_http_client_cleanup(client) == ESP_OK);
esp_http_client_config_t config_with_hostname_path = {
.host = "httpbin.org",
.path = "/get",
};
client = esp_http_client_init(&config_with_hostname_path);
TEST_ASSERT(client != NULL);
TEST_ASSERT(esp_http_client_cleanup(client) == ESP_OK);
}