TSG-6704 增加gtest用例
This commit is contained in:
@@ -3,15 +3,54 @@
|
||||
> Author: pxz
|
||||
> Created Time: Tue 29 Sep 2020 10:32:14 AM CST
|
||||
************************************************************************/
|
||||
#include <gtest/gtest.h>
|
||||
#include <aws/external/gtest.h>
|
||||
#include "hos_client.h"
|
||||
|
||||
#define HOS_CONF "../conf/default.conf"
|
||||
#define HOS_BUCKET "hos_test_bucket"
|
||||
|
||||
TEST(hos_verify_bucket, normal)
|
||||
{
|
||||
int ret = -1;
|
||||
hos_client_handle handle = hos_client_create("http://192.168.40.151/hos/", "default", "default", 1);
|
||||
if (hos_create_bucket(handle, "mybcuket"))
|
||||
ret = hos_verify_bucket(handle, "mybucket");
|
||||
EXPECT(HOS_CLIENT_OK, ret);
|
||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, HOS_BUCKET);
|
||||
EXPECT_EQ(hos_instance->result, true);
|
||||
EXPECT_EQ(hos_instance->error_code, 0);
|
||||
EXPECT_STREQ(hos_instance->error_message, "");
|
||||
EXPECT_STREQ(hos_instance->hos_url_prefix, "http://192.168.44.12:9098/hos/");
|
||||
bool result = hos_verify_bucket(HOS_BUCKET);
|
||||
EXPECT_EQ(result, true);
|
||||
EXPECT_EQ(hos_instance->result, true);
|
||||
EXPECT_EQ(hos_instance->error_code, 0);
|
||||
EXPECT_STREQ(hos_instance->error_message, "");
|
||||
EXPECT_STREQ(hos_instance->hos_url_prefix, "http://192.168.44.12:9098/hos/");
|
||||
int ret = hos_shutdown_instance();
|
||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||
EXPECT_EQ(hos_instance->error_code, 0);
|
||||
EXPECT_STREQ(hos_instance->error_message, "");
|
||||
EXPECT_STREQ(hos_instance->hos_url_prefix, NULL);
|
||||
}
|
||||
|
||||
TEST(hos_verify_bucket, not_exits)
|
||||
{
|
||||
hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, HOS_BUCKET);
|
||||
EXPECT_EQ(hos_instance->result, true);
|
||||
EXPECT_EQ(hos_instance->error_code, 0);
|
||||
EXPECT_STREQ(hos_instance->error_message, "");
|
||||
EXPECT_STREQ(hos_instance->hos_url_prefix, "http://192.168.44.12:9098/hos/");
|
||||
bool result = hos_verify_bucket("hos_not_exits_bucket");
|
||||
EXPECT_EQ(result, false);
|
||||
EXPECT_EQ(hos_instance->result, true);
|
||||
EXPECT_EQ(hos_instance->error_code, 0);
|
||||
EXPECT_STREQ(hos_instance->error_message, "");
|
||||
EXPECT_STREQ(hos_instance->hos_url_prefix, "http://192.168.44.12:9098/hos/");
|
||||
int ret = hos_shutdown_instance();
|
||||
EXPECT_EQ(ret, HOS_CLIENT_OK);
|
||||
EXPECT_EQ(hos_instance->error_code, 0);
|
||||
EXPECT_STREQ(hos_instance->error_message, "");
|
||||
EXPECT_STREQ(hos_instance->hos_url_prefix, NULL);
|
||||
}
|
||||
|
||||
TEST(hos_verify_bucket, no_instance)
|
||||
{
|
||||
bool result = hos_verify_bucket("hos_not_exits_bucket");
|
||||
EXPECT_EQ(result, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user