🧪 test: 增加gtest
This commit is contained in:
@@ -53,29 +53,28 @@ static void gtest_hos_instance_init(hos_instance instance)
|
||||
static void hos_callback(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata)
|
||||
{
|
||||
SUCCEED();
|
||||
EXPECT_EQ(result, true);
|
||||
EXPECT_STREQ(bucket, HOS_BUCKET);
|
||||
EXPECT_STREQ(object, (char *)userdata);
|
||||
EXPECT_STREQ(error, NULL);
|
||||
EXPECT_EQ(error, nullptr);
|
||||
EXPECT_EQ(errorcode, 0);
|
||||
ASSERT_EQ(result, true);
|
||||
ASSERT_STREQ(bucket, HOS_BUCKET);
|
||||
ASSERT_STREQ(object, (char *)userdata);
|
||||
ASSERT_STREQ(error, NULL);
|
||||
ASSERT_EQ(error, nullptr);
|
||||
ASSERT_EQ(errorcode, 0);
|
||||
}
|
||||
|
||||
static void hos_bucket_not_exits_cb(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata)
|
||||
{
|
||||
SUCCEED();
|
||||
EXPECT_EQ(result, false);
|
||||
EXPECT_STREQ(bucket, "bucket_not_exits");
|
||||
EXPECT_STREQ(object, (char *)userdata);
|
||||
EXPECT_STREQ(error, "The specified bucket does not exist.");
|
||||
EXPECT_EQ(errorcode, NO_SUCH_BUCKET);
|
||||
ASSERT_EQ(result, false);
|
||||
ASSERT_STREQ(bucket, "bucket_not_exits");
|
||||
ASSERT_STREQ(object, (char *)userdata);
|
||||
ASSERT_STREQ(error, "The specified bucket does not exist.");
|
||||
ASSERT_EQ(errorcode, NO_SUCH_BUCKET);
|
||||
}
|
||||
|
||||
TEST(hos_upload_buff, normal)
|
||||
{
|
||||
hos_instance_s expect_hos_instance;
|
||||
hos_client_handle_t expect_hos_handle;
|
||||
hos_fd_context_t expect_fd_info;
|
||||
data_info_t *data_info = NULL;
|
||||
|
||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||
@@ -86,7 +85,7 @@ TEST(hos_upload_buff, normal)
|
||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||
|
||||
int ret = hos_upload_buf(HOS_BUCKET, "object", HOS_BUFF, strlen(HOS_BUFF), hos_callback, (void *)"object", 0);
|
||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||
ASSERT_EQ(ret, HOS_CLIENT_OK);
|
||||
data_info->rx_bytes[0] += strlen(HOS_BUFF);
|
||||
data_info->rx_pkts[0] += 1;
|
||||
data_info->tx_bytes[0] += strlen(HOS_BUFF);
|
||||
@@ -95,7 +94,7 @@ TEST(hos_upload_buff, normal)
|
||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||
|
||||
ret = hos_shutdown_instance();
|
||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||
ASSERT_EQ(ret, HOS_CLIENT_OK);
|
||||
expect_hos_instance.status = 0;
|
||||
expect_hos_instance.hos_url_prefix = NULL;
|
||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||
@@ -116,7 +115,6 @@ TEST(hos_upload_buff, bucket_not_exits)
|
||||
{
|
||||
hos_instance_s expect_hos_instance;
|
||||
hos_client_handle_t expect_hos_handle;
|
||||
hos_fd_context_t expect_fd_info;
|
||||
data_info_t *data_info = NULL;
|
||||
|
||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||
@@ -127,7 +125,7 @@ TEST(hos_upload_buff, bucket_not_exits)
|
||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||
|
||||
int ret = hos_upload_buf("bucket_not_exits", "object", HOS_BUFF, strlen(HOS_BUFF), hos_bucket_not_exits_cb, (void *)"object", 0);
|
||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||
ASSERT_EQ(ret, HOS_CLIENT_OK);
|
||||
data_info->rx_bytes[0] += strlen(HOS_BUFF);
|
||||
data_info->rx_pkts[0] += 1;
|
||||
data_info->tx_failed_bytes[0] += strlen(HOS_BUFF);
|
||||
@@ -136,7 +134,7 @@ TEST(hos_upload_buff, bucket_not_exits)
|
||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||
|
||||
ret = hos_shutdown_instance();
|
||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||
ASSERT_EQ(ret, HOS_CLIENT_OK);
|
||||
expect_hos_instance.status = 0;
|
||||
expect_hos_instance.hos_url_prefix = NULL;
|
||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||
@@ -157,7 +155,6 @@ TEST(hos_upload_buff, param_error)
|
||||
{
|
||||
hos_instance_s expect_hos_instance;
|
||||
hos_client_handle_t expect_hos_handle;
|
||||
hos_fd_context_t expect_fd_info;
|
||||
data_info_t *data_info = NULL;
|
||||
|
||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2);
|
||||
@@ -168,12 +165,12 @@ TEST(hos_upload_buff, param_error)
|
||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||
|
||||
int ret = hos_upload_buf(NULL, "object", HOS_BUFF, strlen(HOS_BUFF), hos_callback, (void *)"object", 0);
|
||||
EXPECT_EQ(ret, HOS_PARAMETER_ERROR);
|
||||
ASSERT_EQ(ret, HOS_PARAMETER_ERROR);
|
||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||
CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle);
|
||||
|
||||
ret = hos_shutdown_instance();
|
||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||
ASSERT_EQ(ret, HOS_CLIENT_OK);
|
||||
expect_hos_instance.status = 0;
|
||||
expect_hos_instance.hos_url_prefix = NULL;
|
||||
CheckHosInstance(hos_instance, &expect_hos_instance);
|
||||
@@ -193,5 +190,5 @@ TEST(hos_upload_buff, param_error)
|
||||
TEST(hos_upload_buff, not_init_instance)
|
||||
{
|
||||
int ret = hos_upload_buf(HOS_BUCKET, "object", HOS_BUFF, strlen(HOS_BUFF), hos_callback, (void *)"object", 0);
|
||||
EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE);
|
||||
ASSERT_EQ(ret, HOS_INSTANCE_NOT_ENABLE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user