增加hos_init_instance gtest用例

This commit is contained in:
彭宣正
2021-04-26 18:19:16 +08:00
parent 87537258b3
commit 56fea8c87f
3 changed files with 28 additions and 24 deletions

View File

@@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.0)
project(gtest_hos_client)
aux_source_directory(. SRCS)
#aux_source_directory(. SRCS)
include_directories("/opt/MESA/include")
link_directories("/opt/MESA/lib")
link_libraries(hos-client-cpp gtest gtest_main pthread)
#link_libraries(hos-client-cpp gtest gtest_main pthread)
add_definitions(-g -W -Wall)
add_executable(gtest_hos_client ${SRCS})
add_executable(gtest_hos_client gtest_hos_init_instance.cpp)
target_link_libraries(gtest_hos_client hos-client-cpp gtest gtest_main pthread)

View File

@@ -1,21 +0,0 @@
/*************************************************************************
> File Name: gtest_hos_cleint_create.cpp
> Author: pxz
> Created Time: Tue 29 Sep 2020 10:20:49 AM CST
************************************************************************/
#include <gtest/gtest.h>
#include "hos_client.h"
TEST(hos_client_create, normal)
{
hos_client_handle handle = NULL;
handle = hos_client_create("http://192.168.40.151/hos/", "default", "default", 1);
EXPECT_NE((void *)NULL, handle);
}
TEST(hos_client_create, parameter_error)
{
hos_client_handle handle = NULL;
handle = hos_client_create(NULL, "default", "default", 1);
EXPECT_EQ((void *)NULL, handle);
}

View File

@@ -0,0 +1,25 @@
/*************************************************************************
> File Name: gtest_hos_cleint_create.cpp
> Author: pxz
> Created Time: Tue 29 Sep 2020 10:20:49 AM CST
************************************************************************/
#include <aws/external/gtest.h>
#include "hos_client.h"
TEST(hos_init_instance, normal)
{
hos_instance hos_instance = hos_init_instance("../conf/default.conf", "hos_default_conf", 1, "hos_test_bucket");
EXPECT_EQ(hos_instance->result, true);
int ret = hos_shutdown_instance();
EXPECT_EQ(ret, HOS_CLIENT_OK);
}
TEST(hos_open_fd, buffer)
{
hos_instance hos_instance = hos_init_instance("../conf/default.conf", "hos_default_conf", 1, "hos_test_bucket");
EXPECT_EQ(hos_instance->result, true);
int fd = hos_open_fd("hos_test_bucket", "hos_test_object", NULL, NULL, 0, BUFF_MODE);
EXPECT_EQ(fd, 3);
int ret = hos_shutdown_instance();
EXPECT_EQ(ret, HOS_CLIENT_OK);
}